Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

PMS as a service

cjmurphcjmurph Members, Plex Pass Posts: 347 Plex Pass
edited June 10 in Windows

This post will always contain the latest version of the Plex service wrapper.
This is not official or affiliated with Plex in any way and was originally made for personal use. Treat it as such and please don't bug the Plex devs about it. (bug them about Plex not running as a service natively by all means :P) feel free to post your questions here and I will do my best to help.

If you are having problems, the first question will be whether it runs ok when not being run as a service. Please ensure you can get Plex up and running fine on it's own.

Please read all of this post, there is lots of information covering the most common problems (Mapped drives, different user accounts etc)

The service application was created to enable Plex Media Server to operate as a service in windows.
It has been reported to work on the following OS's and requires .net framework 4 is installed:

  • Windows Server 2003
  • Windows Home Server V1
  • Windows Server 2008 R2
  • Windows Home Server 2011
  • Windows Server 2012 R2
  • Windows Server 2012 Essentials
  • Windows XP
  • Windows 7
  • Windows 8
  • Windows 8.1
  • Windows 10

Latest version is 1.1.2. It is open source and up on the github if you want to build it yourself: https://github.com/cjmurph/PmsService

There is a built copy available under releases on the github here: https://github.com/cjmurph/PmsService/releases

To update Plex Media Server:
1. Stop the plex using the service task bar application
2. Run the plex installer to do the upgrade as usual.
3. When the installer is complete, start Plex using the service task bar application.

[WARNING] Read below if you intend to change the service account
If you change the service account type or the service user account from your current configuration, your application data (and therefore your library) will not be available when you start Plex.
If you want to run the service under a different account, Then you should first move your Plex application data folder to a common folder (Personally I have mine on a second drive of my server "D:\Plex").
If the application data is left under the previous account's folder, then the new account will not have permission to get to it.
Once you have the application data in a common place, after starting Plex with the new credentials, go to the web interface -> server settings -> general -> show advanced -> "The path where local application data is stored" and change this to the location you just moved your Plex application data to. Restart Plex and you should be good to go.

When asked for your credentials during install make sure you fully qualify the user name.
If you are on a domain, the username is entered as domain\username.
If you aren't on a domain, the domain is the computer itself so replace the domain name with the computer name eg. (mycomputersname\username OR .\username).

The install includes a tray application to start and stop Plex, view logs for the service and open the Plex web manager.

There is a large amount of extra information in this thread https://forums.plex.tv/topic/23711-running-pms-as-a-service-in-whs which is where this application was born from.

Media location:
When Plex runs as a service, there is no user session created. Plex will run in a non-interactive session (session 0). This means that any drive mappings you have created will not be available.
If your media is located on a network device, Plex sections must be set up to look at a UNC path NOT a mapped drive.

Auxiliary applications:
Applications you want to have running with Plex. An example is Plexconnect, the python script for using plex with an apple TV.
I've added this after a request from a user to wrap Plexconnect the same way I did Plex, I figured it would work OK in the same service. I don't use Plexconnect personally but I tested this new system with several other applications and they all ran up fine.

To add an auxiliary application, using the task bar icon, go to settings, you will get a new window. click the add button to add a new application, and the remove button to remove the currently selected one.
Name is a user friendly name for the application, file is the file to execute and arguments is any command line arguments you want to add.

Save the settings and the next time the service is started the application you specified will start too. Check the logs (again through the task bar icon) to see how you got on.

I would suggest making sure that the application runs as expected in a normal user session BEFORE attempting to run it as an auxiliary application.

If you are installing Plex for the first time, I'd still recommend moving the application data folder, the user folder isn't the best spot.

If you like the software, buy me a beer :)

Enjoy,

cjmurph.

Tagged:
«13456740

Comments

  • cjmurphcjmurph Members, Plex Pass Posts: 347 Plex Pass
    edited December 2014

    Issues:

    Webkit based channels will not work while Plex is running as a service.

    Update via web interface is not a good idea. The service wrapper will attempt to keep Plex alive and restart it during the update. Stick with the traditional method for now.

  • cjmurphcjmurph Members, Plex Pass Posts: 347 Plex Pass

    Reserved

  • sa2000sa2000 Members, Plex Pass, Plex Ninja, Plex Team Member Posts: 27,540 Plex Team Member
    edited February 2014

    Thank you cjmurph for this excellent package which I have now been running for some time on Windows 7 and it works wonderfully

    It is necessary to ensure that Plex Media Server does not automatically start to run on start because the Service will make sure that happens. If Plex Media Service is left to auto start, then you would end up with 2 instances running. The Plex Media Server Service install program removes the Windows Registry that auto starts Plex Media Server, however this does not help the case when a user wants to run Plex Media Server in a different windows account from the one used for installing it.

     

    So for anybody that runs Plex Media Server in a different Windows User Account from the one used for Installing Plex Media Server, you will need to make sure the Plex Media Server does not start automatically on Logging Into the install user account and this can be done in one of ways:

     

    1, Let is start in the wrong user account and then uncheck the Auto Start option in the Plex Media Server System Tray icon options and Exit Plex Media Server,

     

    You will need to restart the Plex Media Server Server Service as well for the normal account as having two instances of Pllex Media Server on the same computer concurrently leads to indeterminate results for the tcp ports the server listens on.

     

    or

     

    2. Do not let it start in the wrong account and make sure you un-tick Launch at the end of Plex Media Server Upgrade or Install or Repair and

    in the install account where you do not want Plex Media Server to start automatically, delete the following Registry key with Regedit:

     

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\Plex Media Server

     

    I personally use option 2. I use the Plex Media Server Service Tray icon in the Admin Account. In fact I never sign in to the Plex account that runs the service.

    Help given free on forums.            Fee-Based Personal Support & Help.        

    _______________________________________________________________________________________

    Plex Support Information              Troubleshooting               FAQs

    Plex Media Server:   Reporting Issues        Plex Web App: Debug Log    Plex Apps: Support pages and Logs    Logs: All Logs

    For list of 3rd party programs and malware / adware crashing Plex Media Server and mswsock.dll on windows, see Repeated crashing of Plex Media Server on Windows
     
  • MirabisMirabis Members, Plex Pass Posts: 69 Plex Pass

    Hmm interesting, I've always used srvany.exe with plex to make it run as a service..

    Will try this over the weekend :)

    Plex Media Server: Windows Server 2012 R2, Xeon E5-2630v3 (8c16T) @2.4Ghz, 32GB Ram 2133mhz DDR4, Kingston SSDNOW V300, 7x 3TB WD RED + 4x 4TB WD RED & 4x SSD Cache (Storage Spaces - Parity)
    Clients: 12 +/- (iOS, Samsung TV, Chromecasts & Android Tablets)

    Network: 500mbps/500mbps , Netgear R7000 (12dbi) + WNDR3700 (dd-wrt)

  • doogiedoogie Members, Plex Pass Posts: 12 Plex Pass

    Thanks for this - working great on Server 2012 R2.

    Plex Media Server Asus P9D-M | Xeon E3-1240v3 | 16GB RAM | HighPoint RocketRAID 2720 | 4x WD Red 3TB (RAID5) | 2x Corsair M4 256GB | Windows Server 2012 R2

    In-House: HD HomeRun Prime / NextPVR / XBMC

    In the wild: Roku 2 XS | Samsung Galaxy S4 | Nokia Lumia 928 | iPad 2

  • SkOrPnSkOrPn Members Posts: 95 ✭✭

    Working Brilliantly on WHS2011. Thanks again...

  • chewybaca96chewybaca96 Members, Plex Pass Posts: 1 Plex Pass

    Thank you.   As an IT professional, this has saved Plex for use in my network.  I've been using TVersity for quite some time but it has it's own limitations.  The layout and thought that has been put into Plex is great, but being able to run as a service is a must for my environment.

    FYI running it on a Server 2008R2 VM under a clustered Hyper-V environment.

    To note again from above, when you install this, you must use the same credentials you used to install the Plex server otherwise it will not function properly.

    Thanks again for your work.

  • grayfoxliquidgrayfoxliquid Members Posts: 1

    Thank you cjmurph, works also on Windows Server 2012 Essentials (no R2)

  • joelk2joelk2 Members Posts: 2

    so i had my whs11 server running brilliantly until it restarted last night and now my plex doesnt run unless i am logged in (cant remember exactly how i set it up originally but it was working)

    anyways, in an attempt to rectify my issues i downloaded your lovely plex service thingymajig.

    i install and add my credentials, i get the little tray icon and all that.

    i log off and plex still isnt working.

    log on and it works, so i click the tray icon (for your program) and i see i need to start the service.

    i click start service but get an unhandled error. 

    any ideas?

  • sa2000sa2000 Members, Plex Pass, Plex Ninja, Plex Team Member Posts: 27,540 Plex Team Member
    joelk2 wrote on January 17 2014, 12:16 PM: »

    so i had my whs11 server running brilliantly until it restarted last night and now my plex doesnt run unless i am logged in (cant remember exactly how i set it up originally but it was working)

    anyways, in an attempt to rectify my issues i downloaded your lovely plex service thingymajig.

    i install and add my credentials, i get the little tray icon and all that.

    i log off and plex still isnt working.

    log on and it works, so i click the tray icon (for your program) and i see i need to start the service.

    i click start service but get an unhandled error. 

    any ideas?

    Windows Event Log will show the exact error. 

    I did have permissions issue initially on ProgramData folder for the log file access - path/folder might be different on WHS.

    Suggest looking in the System and Application Event logs for Plex related entries at time of starting the service

    Also check syntax for credentials    domain\username or .\username 

    Help given free on forums.            Fee-Based Personal Support & Help.        

    _______________________________________________________________________________________

    Plex Support Information              Troubleshooting               FAQs

    Plex Media Server:   Reporting Issues        Plex Web App: Debug Log    Plex Apps: Support pages and Logs    Logs: All Logs

    For list of 3rd party programs and malware / adware crashing Plex Media Server and mswsock.dll on windows, see Repeated crashing of Plex Media Server on Windows
     
  • cjmurphcjmurph Members, Plex Pass Posts: 347 Plex Pass
    joelk2 wrote on January 17 2014, 12:16 PM: »

    so i had my whs11 server running brilliantly until it restarted last night and now my plex doesnt run unless i am logged in (cant remember exactly how i set it up originally but it was working)

    anyways, in an attempt to rectify my issues i downloaded your lovely plex service thingymajig.

    i install and add my credentials, i get the little tray icon and all that.

    i log off and plex still isnt working.

    log on and it works, so i click the tray icon (for your program) and i see i need to start the service.

    i click start service but get an unhandled error.

    any ideas?


    Hi,

    First, to be on the safe side, ensure Plex isn't running when you try and start the service. It should work, but if the service account and the current logged on user account are different, you may get issues.

    Second, make sure the Plex user (the user account you used when installing the service) has write permission on the programdata folder.

    If both the above are ok, please post the service log, accessible from the tray icon.

    Also, thanks everyone for updates on the os' you have tested on. I'll update the first post.
  • joelk2joelk2 Members Posts: 2
    sa2000 wrote on January 17 2014, 12:30 PM: »

    Windows Event Log will show the exact error. 

    I did have permissions issue initially on ProgramData folder for the log file access - path/folder might be different on WHS.

    Suggest looking in the System and Application Event logs for Plex related entries at time of starting the service

    Also check syntax for credentials    domain\username or .\username 

    thanks.

    :ph34r: restarted and it works now.

    shoulda tried that first really after all "it is windows"

  • sa2000sa2000 Members, Plex Pass, Plex Ninja, Plex Team Member Posts: 27,540 Plex Team Member
    joelk2 wrote on January 17 2014, 12:54 PM: »

    thanks.

    :ph34r: restarted and it works now.

    shoulda tried that first really after all "it is windows"

    Strange though that it was an exception that was generated

    Would still be worth checking:

    - the windows event logs,

    - task manager with 'show processes for all users' to ensure that only one instance of Plex Media Server.exe running and also

      that there is a process for PlexMediaServer-Service.exe

    - the Plex Media Server Service log file (via system tray service icon ) 

    Help given free on forums.            Fee-Based Personal Support & Help.        

    _______________________________________________________________________________________

    Plex Support Information              Troubleshooting               FAQs

    Plex Media Server:   Reporting Issues        Plex Web App: Debug Log    Plex Apps: Support pages and Logs    Logs: All Logs

    For list of 3rd party programs and malware / adware crashing Plex Media Server and mswsock.dll on windows, see Repeated crashing of Plex Media Server on Windows
     
  • dreday28dreday28 Members Posts: 3

    I'm getting a .NET Framework error saying "unhandled exception". In the details is mentions somehting about JIT. I'm running  the newest .NET Framework 4.5.1. I also see in the log files it says "Plex Media Server does not appear to be installed!".

  • cjmurphcjmurph Members, Plex Pass Posts: 347 Plex Pass
    dreday28 wrote on January 17 2014, 8:33 PM: »

    I'm getting a .NET Framework error saying "unhandled exception". In the details is mentions somehting about JIT. I'm running the newest .NET Framework 4.5.1. I also see in the log files it says "Plex Media Server does not appear to be installed!".


    So I guess the obvious has to be asked... Is Plex Media server installed? You wouldn't be the first person to install the client by mistake.
  • dreday28dreday28 Members Posts: 3
    cjmurph wrote on January 17 2014, 10:56 PM: »

    So I guess the obvious has to be asked... Is Plex Media server installed? You wouldn't be the first person to install the client by mistake.


    It's not installed but that's because Plex isn't compatible with server 2008 r2. When I tried installing it said it wasn't compatible. I figured the PMS as a service was a way around it
  • sa2000sa2000 Members, Plex Pass, Plex Ninja, Plex Team Member Posts: 27,540 Plex Team Member
    dreday28 wrote on January 18 2014, 2:47 PM: »

    Plex isn't compatible with server 2008 r2. When I tried installing it said it wasn't compatible. 

    Google search as this below shows people are using Plex Media Server on Windows Server 2008 R2

    site:forums.plex.tv "server 2008 r2"

    Maybe you have a corrupt incomplete download for Plex Media Server (versions are 0.9.8.18 general or 0.9.9.0 PlexPASS)

    We had lots of such examples. It should be circa 60.1Mb in size and file properties should show a Digital Signatures tab with certificate from Plex Inc

    Help given free on forums.            Fee-Based Personal Support & Help.        

    _______________________________________________________________________________________

    Plex Support Information              Troubleshooting               FAQs

    Plex Media Server:   Reporting Issues        Plex Web App: Debug Log    Plex Apps: Support pages and Logs    Logs: All Logs

    For list of 3rd party programs and malware / adware crashing Plex Media Server and mswsock.dll on windows, see Repeated crashing of Plex Media Server on Windows
     
  • cjmurphcjmurph Members, Plex Pass Posts: 347 Plex Pass
    dreday28 wrote on January 18 2014, 2:47 PM: »

    It's not installed but that's because Plex isn't compatible with server 2008 r2. When I tried installing it said it wasn't compatible. I figured the PMS as a service was a way around it

    It is compatible. That's what I use. I'd follow sa2000's suggestion and download it again.
  • richbutler1@gmail.comrichbutler1@gmail.com Members, Plex Pass Posts: 34 Plex Pass

    A special thank you to cjmurph for making my setup with a home server work flawlessly, just the way I wanted it to!  I was finagling with a few other methods and nothing was working quite right, until this  :D My Rokus thank you as well making them my go to device for anything streaming.(at home)

  • DarkLogixDarkLogix Members, Plex Pass Posts: 24 Plex Pass

    Thanks for putting this together

    I don't suppose you could make  alist of the steps to properly change it to use a differant user than was used to install plex?

«13456740
Sign In or Register to comment.