There are two problems here, I'll address both of them.
The syslog error is related to a problem with shutdown, rather than startup (separate from the problem starting the server)
On Shutdown, the plex.sh script is run twice. The first time it works "Stopping Plex Media Server" shows in the syslog, and the second time I get the annoying error "Plex Media Server hasn't been enabled or started ..." because the PID File has already been deleted from the first time it was run. The error should be harmless but I changed "2" (error) to "1" (warning) in plex.sh because I get emails for lvl 2 errors...
Code: Select all
stop)
if [ ! -f "$PID_FILE" ]; then
logMsg="Plex Media Server hasn't been enabled or started ..."
echo $logMsg
/sbin/log_tool -t 2 -a "$logMsg"
exit 0
TO:
Code: Select all
stop)
if [ ! -f "$PID_FILE" ]; then
logMsg="Plex Media Server hasn't been enabled or started ..."
echo $logMsg
/sbin/log_tool -t 1 -a "$logMsg"
exit 0
But then we still have the startup issue to figure out, the Plex server doesn't start on system startup.
The 5 second sleep change that father_mande vaguely mentioned is already present in my version of plex.sh, and is not working for me.
And the PlexMediaServer was already the last entry in the qpkg.conf. I had to edit some code:
Before:
Code: Select all
#Wait a little bit, since new firmware seems to cause a race condition
sleep 5
ulimit -s 3000
cd ${QPKG_DIR}
./Plex\ Media\ Server &
I took a brute force approach to starting it (Loop and try to start it 10 times). It's not pretty, but it works (always on the second try for me)
After:
Code: Select all
#Wait a little bit, since new firmware seems to cause a race condition
#sleep 5
ulimit -s 3000
cd ${QPKG_DIR}
for (( i=1; i<=10; i=i+1 ))
do
if [ ! -f "$PID_FILE" ]; then
logMsg="Plex: No PID file found: attempting to start..."
echo $logMsg
/sbin/log_tool -t 0 -a "$logMsg"
./Plex\ Media\ Server &
sleep 10
else
logMsg="Plex was started on attempt [$i]..."
echo $logMsg
/sbin/log_tool -t 0 -a "$logMsg"
exit 0
fi
if [ ! -f "$PID_FILE" ]; then
logMsg="Plex did not start after 10 attempts, ugh!..."
echo $logMsg
/sbin/log_tool -t 2 -a "$logMsg"
fi
done
Make sure you backup your plex.sh file
before you edit in case you nerf it while editing.
You can test the script via command line
Code: Select all
> cd /etc/init.d
> plex.sh stop
> plex.sh start
File locations:
There is a softlink to plex.sh here:
/etc/init.d/plex.sh --> /share/MD0_DATA/.qpkg/PlexMediaServer/plex.sh
The qpkg.conf is here - /mnt/HDA_ROOT/.config/qpkg.conf
The install (if you care) is here:
QPKG_DIR = /share/MD0_DATA/.qpkg/PlexMediaServer/Library/Plex Media Server
Plex Logs are here:
/share/MD0_DATA/.qpkg/PlexMediaServer/Library/Plex Media Server/Logs
QNAP Firmware 4.2.2
Plex version - 1.3.3.3148