Using sh scripting, and the curl command, though, you can make an automatic script to check the operation of the website, and restart it, making an entry in the system log files that the script stopped. If you use AiMaster, you should get a prompt that the script has stopped, so you can go in and check if everything is working correctly.
I'm going to give a couple of example scripts here, one I've already put out in the Plex sub-forums and one that's new.
The old one first. this is checking if Plex Media Server is running:
Code: Select all
#!/bin/sh
curl -I -m 8 "http://localhost:32400/web/index.html"
if [ "$?" -ne "0" ]
then
/usr/sbin/syslog --log 0 --level 0 --user admin --event "Remote Access to Plex is unavailable"
/usr/local/AppCentral/plexmediaserver/CONTROL/start-stop.sh restart
fi
exit 0
the next line is a built in command called curl. It looks at the website you have in it's arguments, to see if there is an output from the site. If so, it exits the script, if not, then it executes the lines between the then and fi. So, assume that Plex has stopped, and this script found it. The line that has "/usr/sbin/syslog ..." in it writes the error to the log file. The next line /usr/local/App Central/ ..." then calls the start-stop.sh script for Plex to have it restart. If you look in the Plex Forums here, you will see a few other things that need to be done to make that happen, though.
This next script is also driven towards Plex, but it calls a tool called PlexPy. PlexPy is a web front-end for a perl script called PlexWatch. Plex Watch looks at the Plex Media Server's log files and determines who, what and when your media has been streamed from the NAS. The PlexPy script just presents this data in a clean interface. Here's the script for checking it:
Code: Select all
#!/bin/sh
curl -I -m 8 "http://localhost:8181/home";
if [ "$?" -ne "0" ]
then
/usr/sbin/syslog --log 0 --level 0 --user admin --event "PlexPy isn't running: Starting it"
/volume1/misc/PlexPy/PlexPy.py -d
fi
exit 0
These 2 scripts are called from a third script, listed here:
Code: Select all
#!/bin/sh
/volume1/misc/CkPlexPy.sh
sleep 5
/volume1/misc/CkPlex.sh
exit 0
The last step to put this all together is editing the cron files for making things happen in certain time frames. Using WinSCP or an equivalent product, navigate to this file: /var/spool/cron/crontabs/root Root is a file, even though it has no extension. Just double-click it to open it in WinSCP's editor to see these lines: (I have added a few to make editing easier to keep track of in this file.)
Code: Select all
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
*/20 * * * * /volume1/misc/CkApps.sh
Code: Select all
* */20 * * * /pathtoscript/scripthere