Updated Install as a daemon (markdown)

JonnyWong16
2018-03-10 08:31:44 -08:00
parent 5ad892d6f2
commit 41ca6f8bcb

@@ -1,114 +1 @@
These steps are presented as guidelines. Your results may vary, depending on operating system, installation path and other settings.
## Windows
### Interactive
This will start PlexPy in the background when you login to Windows without the command prompt.
* Make sure PlexPy is shutdown. `PlexPy > Settings > Shutdown`
* Create a new shortcut ([screenshot](http://i.imgur.com/CBA2D6f.png)) in your startup folder with
* Target: `C:\Python27\pythonw.exe C:\PlexPy\PlexPy.py`
* Start in: `C:\Python27`
* Start PlexPy with the shortcut
### Non Interactive
This will start PlexPy in the background when your computer starts, regardless of whether you are logged in.
* Make sure PlexPy is shutdown. `PlexPy > Settings > Shutdown`
* Create a new text file and [enter the following line](https://i.imgur.com/KYT8rCM.png): `Start C:\Python27\pythonw.exe C:\PlexPy\PlexPy.py`
* Save the file in your PlexPy folder as `PlexPy.cmd` (e.g. `C:\PlexPy\PlexPy.cmd`)
* Open the "Run" dialog window (<kbd>Win</kbd>+<kbd>R</kbd>) and run `%windir%\system32\taskschd.msc` to open your Windows Task Scheduler.
* Create a new task with the following settings:
* [General](https://i.imgur.com/Hr0Hf6i.png):
* Name: PlexPy
* (•) Run whether user is logged on or not
* Configure for: Windows 10 (select your own Windows version)
* [Triggers](https://i.imgur.com/UZJYxsk.png):
* Add a new trigger:
* Begin the task: At startup
* [✓] Delay task for: 30 seconds (to allow your server to start up, adjust as necessary)
* Click OK
* [Actions](https://i.imgur.com/QsfV2SO.png):
* Add a new action:
* Action: Start a program
* Program/script: `C:\PlexPy\PlexPy.cmd`
* Click OK
* [Settings](https://i.imgur.com/N51JmMb.png):
* [✓] Allow task to be run on demand
* [✓] Run task as soon as possible after a scheduled start is missed
* [✓] If the task fails, restart every: 1 minute
* Attempt to restart up to: 3 times
* [✓] If the running task does not end when requested, force it to stop
* If the task is already running, then the following rule applies: Do not start a new instance
* Click OK
* PlexPy should show up in the [list of Active Tasks](https://i.imgur.com/eE3I25I.png).
* Double click on the task, then [click "Run" on the right hand side](https://i.imgur.com/Ms3JHif.png). The status will change the "Running".
* Once PlexPy has started, the [status should change back to "Ready" and the last run result should say "The operation completed successfully (0x0)"](https://i.imgur.com/6wCl9F4.png).
* In your Windows Task Manager, there should be a ["pythonw.exe" background process running](https://i.imgur.com/y92k9zb.png).
## Linux (systemd)
Use the following service script for CentOS, Fedora, openSUSE, Ubuntu, etc. that uses systemd. The instructions are in the script file.
* https://github.com/JonnyWong16/plexpy/blob/master/init-scripts/init.systemd
## Ubuntu (<15.10)
This installation assumes PlexPy is installed to `/opt/plexpy`. Make sure all paths are correct and accessible. A common mistake is that a daemon user has no read and/or write permissions.
For other versions of Ubuntu:
* Make sure PlexPy is shutdown. `PlexPy > Settings > Shutdown`
* `cd /opt/plexpy`
* `sudo touch /etc/default/plexpy`
* Optional:
* `sudo adduser --system --no-create-home plexpy`
* `sudo chown plexpy:nogroup -R /opt/plexpy`
* Adjust settings in `/etc/default/plexpy`. See the comments in [`/opt/plexpy/init-scripts/init.ubuntu`](https://github.com/JonnyWong16/plexpy/blob/master/init-scripts/init.ubuntu) for the list of parameters.
* `sudo chmod +x /opt/plexpy/init-scripts/init.ubuntu`
* `sudo ln -s /opt/plexpy/init-scripts/init.ubuntu /etc/init.d/plexpy`
* `sudo update-rc.d plexpy defaults`
* `sudo service plexpy [start | stop | reload | restart]`
## Mac OS X
Tested on Mac OS X 10.11.3. Assumes PlexPy is installed to `/Applications/PlexPy/`
If you need to specify a version of Python, edit `com.JonnyWong16.plexpy.plist`
* Make sure PlexPy is shutdown. `PlexPy > Settings > Shutdown`
* `cp /Applications/PlexPy/init-scripts/init.osx ~/Library/LaunchAgents/com.JonnyWong16.plexpy.plist`
* To start PlexPy run `launchctl load ~/Library/LaunchAgents/com.JonnyWong16.plexpy.plist`
* To stop PlexPy run `launchctl unload ~/Library/LaunchAgents/com.JonnyWong16.plexpy.plist`
## FreeBSD
This assumes PlexPy is installed to `/usr/local/share/` as per installation instructions, and user is _sabnzbd. You can make your own user too: `sudo adduser`
* Make sure PlexPy is shutdown. `PlexPy > Settings > Shutdown`
* Ensure user permissions are correct: `sudo chown -R _sabnzbd:_sabnzbd /usr/local/share/plexpy`
* Copy init script: `sudo cp /usr/local/share/plexpy/init-scripts/init.freebsd /usr/local/etc/rc.d/plexpy`
* Enable at boot: `sudo sysrc plexpy_enable="YES"`
* To start `sudo service plexpy start`
Optional:
* If you need to change user: `sudo sysrc plexpy_user="USERNAME"`
* Run from another directory: `sudo sysrc plexpy_dir="DIRECTORY"`
## FreeNAS
Instructions by [Supa on the FreeNAS forums](https://forums.freenas.org/index.php?threads/how-to-install-plexpy-in-a-freenas-9-3-jail.38589/#post-234202).
This assumes PlexPy is installed to `/usr/local/share/` as per installation instructions, and user is `root`.
To automate the PlexPy script just do this in the jail shell (in root directory):
* Make sure PlexPy is shutdown. `PlexPy > Settings > Shutdown`
* Ensure user permissions are correct: `chown -R root:wheel /usr/local/share/plexpy`
* Copy init script: `cp /usr/local/share/plexpy/init-scripts/init.freenas /usr/local/etc/rc.d/plexpy`
* Enable at boot: `sysrc plexpy_enable="YES"`
* Set user to run: `sysrc plexpy_user="root"`
* To start `service plexpy start`
* You can use `service plexpy [start | stop | restart | status]` to start/stop/restart or check the status of the PlexPy service
Optional:
* If you need to change user: `sysrc plexpy_user="USERNAME"`
* Set user permissions for the plexpy directory: `chown -R USERNAME:GROUPNAME /usr/local/share/plexpy`
* Run from another directory: `sysrc plexpy_dir="DIRECTORY"`
**The wiki has moved to https://github.com/Tautulli/Tautulli-Wiki/wiki**.