Preliminary instructions to run daemon on OSX

I know f00b4r said instructions are forthcoming but can anyone tell me how to run the new daemon code until then? Cheers.

github pull request/commit comment:

usage:

cd /PlexConnect
sudo ./PlexConnect_daemon.bash start
sudo ./PlexConnect_daemon.bash status
sudo ./PlexConnect_daemon.bash stop

Ok, not all of them at once... but... I think you get it. ;-)

Thx baa. I’ll give it a go.

Next question for anyone who knows. How can I make this run at startup?

That depends on the OS but the framework is there if people want to jump in to help for any specific OS’es.

I am referring to OSX as the title of the thread indicates.

I know f00b4r said instructions are forthcoming but can anyone tell me how to run the new daemon code until then? Cheers.


What's daemon and what does it do? How does it help plex? Thanks.


Sent from my iPhone using Tapatalk - now Free

It allows Plexconnect to run as a background process so it lets you close the terminal window without killing Plexconnect.

It lets you launch PlexConnect and then shut the terminal window without killing PlexConnect, especially useful if you are starting it remotely through a SSH session.

It also means that using launchctl (OSX/Ubuntu) or equivalents on other *nix OS’es it is possible to:

  • automatically start PlexConnect at boot even prior to login
  • auto start PlexConnect as root without requiring a password (no security concerns over stored passwords)
  • have the OS automatically restart PlexConnect if it crashes
  • allow a Mac to sleep and wake up (PlexConnect will work on wake)
  • have the OS automatically shutdown PlexConnect cleanly when the machine is shutdown


    It is a good thing :wink: but it does need some work on the launchctl part or equivalent for the different OS’es.


    NB this is only for *nix OS’es such as OSX, Linux, FreeBSD etc…

OK, I have been trying to make a plist to put in Library/Launchagents that will start the daemon on login (at least this is what I think you are supposed to do). The plist looks like this (cobbled together by using Lingon and looking at other examples on the web) but it doesn't work. any suggestions?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Disabled
KeepAlive
Label
com.plexconnect.daemon
WorkingDirectory
/Users/institute11/Desktop/PlexConnect-master/
ProgramArguments
sudo
/Users/institute11/Desktop/PlexConnect-master/PlexConnect_daemon.bash
start
QueueDirectories
RunAtLoad
WatchPaths

Did someone say osx? Check my signature :slight_smile:


Personally autostarting plexconnect with anything but automator seemed to be a pain on osx in my experience. I only use launchctl for autostarting and keeping alive pms. Plexconnect never would play nice with launchctl.


i belive your answer lies here post #97:


http://forums.plexapp.com/index.php/topic/70149-has-anyone-created-an-applescriptapplication-to-launch-plexconnect-at-startup/page-12


You will have to modify a few things but it is the best ive seen thats works 100% of the time.

Did someone say osx? Check my signature :)

Personally autostarting plexconnect with anything but automator seemed to be a pain on osx in my experience. I only use launchctl for autostarting and keeping alive pms. Plexconnect never would play nice with launchctl.

Only because the code was not there but it is now ;)

Launchctl is a much better method as it will auto restart on crashes and no password is stored.

I am going to have a play about as soon as i get a chance on my desktop and the other half is not using PlexConnect but anyone else feel free to jump in.

If thats the case let me see if I can dig out my old plist for plexconnect. Oops nm it was this guy that made a plexconnect plist. I made a pms plist duh :stuck_out_tongue:

https://gist.github.com/chrishulbert/5772931


Here is mine if needed (for pms):

https://github.com/wahlmanj/com.plex.pms.plist

I've been playing with it and here is what I have so far:

save this as /Library/LaunchDaemons/com.plex.plexconnect.plist (replace  2 times with correct path)

<?xml version="1.0" encoding="UTF-8"?>



    Label
        com.plex.plexconnect
        OnDemand
        
        ProgramArguments
        
            python
            /PlexConnect_daemon.py
        
        RunAtLoad
        
        UserName
        root
        WorkingDirectory
        
        ServiceDescription
        PlexConnect
        

then in terminal 

sudo chmod 644 /Library/LaunchDaemons/com.plex.plexconnect.plist
sudo chown root:wheel /Library/LaunchDaemons/com.plex.plexconnect.plist

now let launchctl start it up without rebooting

sudo launchctl load /Library/LaunchDaemons/com.plex.plexconnect.plist

remove it again from launchctl ...

sudo launchctl unload /Library/LaunchDaemons/com.plex.plexconnect.plist

i'm not using PlexConnect_daemon.bash on mac yet because I have to investigate whether the mac cleans up the stored pid file on reboot....

if it doesn't PlexConnect_daemon.py will not start anymore until the file is cleaned up....

Still you will run into the problem of pms not starting prior to log in if you have a password on osx without autologin… But ive figured that one out as well :slight_smile:

http://forums.plexapp.com/index.php/topic/81127-plex-media-center-automatic-startup-applescript-login-option-osx/


Here is the app I made to use with login items to enable pms to autostart if anyone needs it (fastuser.zip). Also the older one that enables the lockcreen instead (lock.zip). Both require you to add them to login items and enable automatic login. All of this is editable within settings/users & groups. This is only if you have a password and want to load pms automatically and still have a password protected machine @ boot (Fast user & lock)

https://forums.plex.tv/topic/81127-plex-media-center-automatic-startup-applescript-login-option-osx/#entry466470

How come there’s nothing cool for windows?





Sent from my iPhone using Tapatalk - now Free

Because you have not written it yet?

But seriously - there's a handful of people working on this. Patience! :)

I've been playing with it and here is what I have so far:

save this as com.plex.plexconnect.plist in the PlexConnect folder (replace  2 times with correct path)

...

now add it to launchctl for automatic startup

sudo launchctl load -w `pwd`/com.plex.plexconnect.plist

On my mac 10.7 this will work only once - after next reboot nothing is started and "launchctl list" won't list this file.

please move the com.plex.plexconnect.plist file in  /Library/LaunchDaemons/