PlexConnect Windows Service

Hi Guys,

A simple and quick quide how to install and remove PlexConnect for aTV as a Windows Service.
Tested with: Windows 7, Windows 8 (32b & 64b).

Good luck!


Install and Start PlexConnect-service

  • Download NSSM: nssm-2.16.zip (187 KB)
  • Put the NSSM-binary in your PlexConnect folder.
  • Start Command-Prompt (Run > cmd) and go to your PlexConnect-folder (cd foldername).
  • Type: nssm install SERVICE-NAME PYTHON-FOLDER "PLEXCONNECT-FOLDER"

    Example: 
    nssm install PlexConnect C:\Python27\python.exe "C:\PlexConnect\PlexConnect.py"
  • Type: net start SERVICE-NAME

    Example: 
    net start PlexConnect
  • Done!

 

Example download: PlexConnect_example.zip (362 KB)

 

Stop and Remove PlexConnect-service

  • Start Command-Prompt (Run > cmd) and go to your PlexConnect-folder (cd foldername).
  • Type: net stop SERVICE-NAME

    Example: 
    net stop PlexConnect
  • Type: nssm remove SERVICE-NAME 

    Example: 
    nssm remove PlexConnect
  • Done!

Rogger,


Looks great. My only question is does NSSM handle closing plexconnect with CTRL C so that the settings changes made through the UI on the ATV are sved to atvsettings.cfg?

Yes... set all your settings in ATVSettings.cfg...

Because CTRL + C does not work with background processes (service), create a little restart script for Windows so you can activate newly set settings, example:

@echo off
net stop PlexConnect
net start PlexConnect
exit

Save as "plexconnect_restart.cmd"

Download: PlexConnect_restart.zip (188 Bytes)

Sorry maybe I did not phrase my question correctly.


Plex connect only saves the atvsettings.cfg file web you ctrl c the python script. This settings file is any changes you have made in the UI on the ATV, ie list v grid view etc


So if you do a net stop or stop the service through the services control panel does NSSM close the script cleanly ie send a ctrl c or does it just kill the python process? Because if it just kills the python process then no changes made in the ATV UI will be saved.

... So if you do a net stop or stop the service through the services control panel does NSSM close the script cleanly ie send a ctrl c or does it just kill the python process? Because if it just kills the python process then no changes made in the ATV UI will be saved.

True... on restarting the service (net stop/start servicename) the ATVSettings.cfg won't be written. Just set your settings once and you'll be ok.

Love the idea. Thanks for sharing. I followed these instructions, but I haven't been able to get PlexConnect to run in the background. According to the nssm command prompt, I was able to install and start the service successfully, as shown here:

C:\Program Files (x86)\PlexConnect>nssm install PlexConnect C:\Python27\python.e

xe "C:\Program Files (x86)\PlexConnect\PlexConnect.py"
Service "PlexConnect" installed successfully!
 
C:\Program Files (x86)\PlexConnect>net start PlexConnect
The PlexConnect service is starting.
The PlexConnect service was started successfully.

However, Trailers doesn't work, and the Windows service manager shows the service as being Paused. I'm running Windows 7 and I've actually tried using the 32-bit and 64-bit versions of nssm, which gave me the same results. Any ideas? Thanks!

Gordon

Not sure how I missed this first time. Definitely trying this out when I get home.

Hi Rogger,

I downloaded the nssm but I did'nt get NSSM-binary. Do I have to copy the complete folder or any particular file?

Please read this: https://github.com/iBaa/PlexConnect/wiki/Install-guides and fix http://forums.plexapp.com/index.php/topic/79540-windows-specific-instructions-for-creating-and-installing-the-ssl-cert/

Hi Rogger,

I downloaded the nssm but I did'nt get NSSM-binary. Do I have to copy the complete folder or any particular file?

When he says "binary" he means the .exe file. So you either want the one from the x64 folder or the x32 folder.

Rogger - if your reply was directed toward me, I believe I've already done all that. I have PlexConnect working with the cert file when I run it without nssm (from the command line). It's the nssm service that won't start correctly.

Send you a PM. Please let me know....

@Rogger

tried the complete setup again. But no go.

08:41:51 PlexConnect: ***
08:41:51 PlexConnect: PlexConnect
08:41:51 PlexConnect: Press CTRL-C to shut down.
08:41:51 PlexConnect: ***
08:41:51 PlexConnect: started: 08:41:51
08:41:51 PlexConnect: IP_self: 192.168.1.2
08:41:51 DNSServer: started: 08:41:51
08:41:51 DNSServer: ***
08:41:51 DNSServer: DNSServer: Serving DNS on port 53.
08:41:51 DNSServer: intercept: ['trailers.apple.com', 'atv.plexconnect'] => 192.
168.1.2
08:41:51 DNSServer: restrain: ['mesu.apple.com', 'appldnld.apple.com', 'appldnld
.apple.com.edgesuite.net'] => 127.0.0.1
08:41:51 DNSServer: forward other to higher level DNS: 8.8.8.8
08:41:51 DNSServer: ***
08:41:52 WebServer: started: 08:41:52
08:41:52 WebServer: ***
08:41:52 WebServer: WebServer: Serving HTTP on 0.0.0.0 port 80.
08:41:52 WebServer: WebServer: Serving HTTPS on 0.0.0.0 port 443.
08:41:52 WebServer: ***
08:41:52 PlexGDM: ***
08:41:52 PlexGDM: looking up Plex Media Server
08:41:52 PlexGDM: ***
08:41:53 PlexGDM: servers discovered: 1
08:41:53 XMLConverter: PlexGDM - PMS: 192.168.1.2:32400
08:42:04 DNSServer: DNS request received!
08:42:04 DNSServer: Source: ('192.168.1.102', 51772)
08:42:04 DNSServer: Domain: p40-buy.itunes.apple.com.akadns.net
08:42:04 DNSServer: ***forward request
08:42:04 DNSServer: -> DNS response from higher level
08:42:04 DNSServer: DNS request received!
08:42:04 DNSServer: Source: ('192.168.1.102', 61453)
08:42:04 DNSServer: Domain: p40-buy.itunes.apple.com.akadns.net
08:42:04 DNSServer: ***forward request
08:42:04 DNSServer: -> DNS response from higher level
08:42:08 DNSServer: DNS request received!
08:42:08 DNSServer: Source: ('192.168.1.102', 62611)
08:42:08 DNSServer: Domain: itunes-cdn.apple.com.akadns.net
08:42:08 DNSServer: ***forward request
08:42:08 DNSServer: -> DNS response from higher level
08:42:08 DNSServer: DNS request received!
08:42:08 DNSServer: Source: ('192.168.1.102', 61333)
08:42:08 DNSServer: Domain: itunes-cdn.apple.com.akadns.net
08:42:08 DNSServer: ***forward request
08:42:08 DNSServer: -> DNS response from higher level
08:42:08 DNSServer: DNS request received!
08:42:08 DNSServer: Source: ('192.168.1.102', 52634)
08:42:08 DNSServer: Domain: ax.init-cdn.itunes.apple.com.akadns.net
08:42:08 DNSServer: ***forward request
08:42:08 DNSServer: -> DNS response from higher level
08:42:08 DNSServer: DNS request received!
08:42:08 DNSServer: Source: ('192.168.1.102', 59617)
08:42:08 DNSServer: Domain: ax.init-cdn.itunes.apple.com.akadns.net
08:42:08 DNSServer: ***forward request
08:42:08 DNSServer: -> DNS response from higher level
08:42:08 DNSServer: DNS request received!
08:42:08 DNSServer: Source: ('192.168.1.102', 65141)
08:42:08 DNSServer: Domain: e673.g.akamaiedge.net
08:42:08 DNSServer: ***forward request
08:42:08 DNSServer: -> DNS response from higher level
08:42:08 DNSServer: DNS request received!
08:42:08 DNSServer: Source: ('192.168.1.102', 64636)
08:42:08 DNSServer: Domain: a771.da1.akamai.net
08:42:08 DNSServer: ***forward request
08:42:08 DNSServer: -> DNS response from higher level
08:42:08 DNSServer: DNS request received!
08:42:08 DNSServer: Source: ('192.168.1.102', 57343)
08:42:08 DNSServer: Domain: trailers.apple.com
08:42:08 DNSServer: ***intercept request
08:42:08 DNSServer: -> DNS response: 192.168.1.2
08:42:08 DNSServer: DNS request received!
08:42:08 DNSServer: Source: ('192.168.1.102', 62388)
08:42:08 DNSServer: Domain: trailers.apple.com
08:42:08 DNSServer: ***intercept request
08:42:08 DNSServer: -> DNS response: 192.168.1.2
 
Here is my settings file
 

[PlexConnect]

logpath = .

enable_dnsserver = True

ip_webserver = 0.0.0.0

prevent_atv_update = True

port_dnsserver = 53

enable_plexconnect_autodetect = True

port_pms = 32400

port_webserver = 80

ip_plexconnect = 0.0.0.0

certfile = c:\plexconnect\assets\certificates railers.pem

ip_dnsmaster = 8.8.8.8

loglevel = Normal

ip_pms = 192.168.178.10

enable_plexgdm = True

port_ssl = 443

I had problems getting this to work on my win7 plex server, I do not have a password at startup so I use this instead of creating a service.  The bat file will do a delay startup of plexconnect, this gives the plex server a chance to startup first

I created a bat file and put it in the startup folder:

@ECHO OFF
 
TIMEOUT /T 30
REM Total Delay = 30 seconds
START C:\plexconnect\plexconnect.py

Worked great, a slight delay would be useful as I found the service starts up before the plex server so if you try and access the server via ATV straight after start up it fails, but hit menu and back and it works so hardly a problem.

I had problems getting this to work on my win7 plex server, I do not have a password at startup so I use this instead of creating a service.  The bat file will do a delay startup of plexconnect, this gives the plex server a chance to startup first

I created a bat file and put it in the startup folder:

@ECHO OFF
 
TIMEOUT /T 30
REM Total Delay = 30 seconds
START C:\plexconnect\plexconnect.py

Alternative:

Rename PlexConnect.py to PlexConnect.pyw.

Click on PlexConnect.pyw and PlexConnect will run in the background. 

To start PlexConnect on Windows logon, make a shortcut to PlexConnect.pyw and place it in your StartUp folder (StartMenu > Startup).

Only one disadvantage; If you want to stop/restart PlexConnect you have to kill the process in the Task Manager (pythonw.exe).

Thanks, Rogger! The pyw tweak worked for me. So simple!

Alternative:

Rename PlexConnect.py to PlexConnect.pyw.

Click on PlexConnect.pyw and PlexConnect will run in the background. 

To start PlexConnect on Windows logon, make a shortcut to PlexConnect.pyw and place it in your StartUp folder (StartMenu > Startup).

Only one disadvantage; If you want to stop/restart PlexConnect you have to kill the process in the Task Manager (pythonw.exe).

Thanks for the suggestion. Definitely the simplest way to go; and best of all; it actually works...

works perfectly on win 8.1, thanks heaps!

Alternative:

Rename PlexConnect.py to PlexConnect.pyw.

Click on PlexConnect.pyw and PlexConnect will run in the background.
To start PlexConnect on Windows logon, make a shortcut to PlexConnect.pyw and place it in your StartUp folder (StartMenu > Startup).

Only one disadvantage; If you want to stop/restart PlexConnect you have to kill the process in the Task Manager (pythonw.exe).


The issue with this is:

- PlexConnect will never be shut done cleanly
- your settings will not get saved if you change them.
- if PlexConnect crashes it will not automatically restart

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.