Open deejvince opened 10 years ago
bump.
what script dit you exactly use to start it?
i setup a startup script in /etc/init.d
here it is:
[~] # cat /etc/init.d/htpc-manager.sh
#! /bin/sh
### BEGIN INIT INFO
# Provides: HTPC-Manager application instance
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts instance of HTPC-Manager
# Description: starts instance of HTPC-Manager using start-stop-daemon
### END INIT INFO
############### EDIT ME ##################
# path to app
APP_PATH=/share/MD0_DATA/.qpkg/HTPC-Manager-master
QPKG_NAME=HTPC-Manager-master
PID_FILE=/tmp/$QPKG_NAME.pid
# path to python bin
DAEMON=/opt/bin/python2.7
# startup args
DAEMON_OPTS=" Htpc.py --pid $PID_FILE --daemon $2"
# script name
NAME=htpc
# app name
DESC=HTPC-Manager
# user
RUN_AS=admin
# PID_FILE=/var/run/htpcmanager.pid
############### END EDIT ME ##################
# QPKG Related - enable when converting to QPKG..
#QPKG_DIR=$(/sbin/getcfg $QPKG_NAME Install_Path -f /etc/config/qpkg.conf)
#temp before qpkg to work as static:
QPKG_DIR=/share/MD0_DATA/.qpkg/HTPC-Manager-master
# CheckQpkgEnabled() { #Is the QPKG enabled? if not exit the script
# if [ $(/sbin/getcfg ${QPKG_NAME} Enable -u -d FALSE -f /etc/config/qpkg.conf) = UNKNOWN ]; then
# /sbin/setcfg ${QPKG_NAME} Enable TRUE -f /etc/config/qpkg.conf
# elif [ $(/sbin/getcfg ${QPKG_NAME} Enable -u -d FALSE -f /etc/config/qpkg.conf) != TRUE ]; then
# /bin/echo "${QPKG_NAME} is disabled."
# exit 1
# fi
#}
ConfigPython(){ #checks if the daemon exists and will link /usr/bin/python to it
#python dependency checking
if [ ! -x $DAEMON ]; then
/sbin/write_log "Failed to start $QPKG_NAME, $DAEMON was not found. Please re-install the Pythton ipkg." 1
exit 1
else
#link python to /usr/bin/python to fix htpc.py processing
/bin/ln -sf $DAEMON /usr/bin/python
fi
}
CheckForOpt(){ #Does /opt exist? if not check if it's optware that's installed or opkg, and start the package
/bin/echo -n " Checking for /opt..."
if [ ! -d /opt/bin ]; then
if [ -x /etc/init.d/Optware.sh ]; then #if optware ,start optware
/bin/echo " Starting Optware..."
/etc/init.d/Optware.sh start
sleep 2
elif [ -x /etc/init.d/opkg.sh ]; then #if opkg, start opkg
/bin/echo " Starting Opkg..."
/etc/init.d/opkg.sh start
sleep 2
else #catch all
/bin/echo " No Optware or Opkg found, please install one of them"
/sbin/write_log "Failed to start $QPKG_NAME, no Optware or Opkg found. Please re-install one of those packages" 1
exit 1
fi
else
/bin/echo " Found!"
fi
}
CheckQpkgRunning() { #Is the QPKG already running? if so, exit the script
if [ -f $PID_FILE ]; then
#grab pid from pid file
Pid=$(/bin/cat $PID_FILE)
if [ -d /proc/$Pid ]; then
/bin/echo " $QPKG_NAME is already running"
exit 1
fi
fi
#ok, we survived so the QPKG should not be running
}
UpdateQpkg(){ # does a git pull to update to the latest code
/bin/echo "Updating $QPKG_NAME"
cd $QPKG_DIR && /opt/bin/git reset --hard HEAD && /opt/bin/git pull HTPC-manager master&& cd - && /bin/sync
}
StartQpkg(){ #Starts the qpkg
/bin/echo "Starting $QPKG_NAME"
cd $QPKG_DIR
PATH=${PATH} ${DAEMON} ${DAEMON_OPTS}
}
ShutdownQPKG() { #kills a proces based on a PID in a given PID file
/bin/echo "Shutting down ${QPKG_NAME}... "
if [ -f $PID_FILE ]; then
#grab pid from pid file
Pid=$(/bin/cat $PID_FILE)
i=0
/bin/kill $Pid
/bin/echo -n " Waiting for ${QPKG_NAME} to shut down: "
while [ -d /proc/$Pid ]; do
sleep 1
let i+=1
/bin/echo -n "$i, "
if [ $i = 45 ]; then
/bin/echo " Tired of waiting, killing ${QPKG_NAME} now"
/bin/kill -9 $Pid
/bin/rm -f $PID_FILE
exit 1
fi
done
/bin/rm -f $PID_FILE
/bin/echo "Done"
else
/bin/echo "${QPKG_NAME} is not running?"
fi
}
case "$1" in
start)
# CheckQpkgEnabled #Check if the QPKG is enabled, else exit
/bin/echo "$QPKG_NAME prestartup checks..."
CheckQpkgRunning #Check if the QPKG is not running, else exit
CheckForOpt #Check for /opt, start qpkg if needed
ConfigPython #Check for Python, exit if not found
# UpdateQpkg #do a git pull
StartQpkg #Finally Start the qpkg
;;
stop)
ShutdownQPKG
;;
restart)
echo "Restarting $QPKG_NAME"
$0 stop
$0 start
;;
*)
N=/etc/init.d/$QPKG_NAME.sh
echo "Usage: $N {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
Bump.
Running check for updates from WebUI, eventually stops the process after update and does not start it again, have to manually do that.. I am running HTPC-Manager on qnap with python 2.7.
2014-01-12 01:53:46 :: htpc.updater :: INFO :: Checking for updates from Source. 2014-01-12 01:53:50 :: htpc.updater :: INFO :: Currently 9 commits behind. 2014-01-12 01:53:55 :: htpc.updater :: INFO :: Attempting update from source. 2014-01-12 01:53:55 :: cherrypy.error :: INFO :: [12/Jan/2014:01:53:55] ENGINE Bus STOPPING 2014-01-12 01:54:00 :: cherrypy.error :: INFO :: [12/Jan/2014:01:54:00] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8085)) shut down 2014-01-12 01:54:00 :: cherrypy.error :: INFO :: [12/Jan/2014:01:54:00] ENGINE Stopped thread '_TimeoutMonitor'. 2014-01-12 01:54:00 :: cherrypy.error :: INFO :: [12/Jan/2014:01:54:00] ENGINE Bus STOPPED 2014-01-12 01:54:00 :: cherrypy.error :: INFO :: [12/Jan/2014:01:54:00] ENGINE Bus EXITING 2014-01-12 01:54:00 :: cherrypy.error :: INFO :: [12/Jan/2014:01:54:00] ENGINE PID file removed: '/tmp/HTPC-Manager-master.pid'. 2014-01-12 01:54:00 :: cherrypy.error :: INFO :: [12/Jan/2014:01:54:00] ENGINE B us EXITED 2014-01-12 01:54:00 :: htpc.updater :: INFO :: Downloading update from https://github.com/styxit/HTPC-Manager/tarball/master 2014-01-12 01:54:00 :: cherrypy.error :: INFO :: [12/Jan/2014:01:54:00] ENGINE Waiting for child threads to terminate... 2014-01-12 01:54:00 :: cherrypy.error :: INFO :: [12/Jan/2014:01:54:00] ENGINE Waiting for thread Thread-13. 2014-01-12 01:54:09 :: htpc.updater :: INFO :: Downloading update complete 2014-01-12 01:54:27 :: htpc.updater :: INFO :: updating files successfull 2014-01-12 01:54:27 :: htpc.updater :: WARNING :: Restarting HTPC Manager after update. 2014-01-12 01:54:27 :: cherrypy.error :: INFO :: [12/Jan/2014:01:54:27] ENGINE Bus STOPPING 2014-01-12 01:54:27 :: cherrypy.error :: INFO :: [12/Jan/2014:01:54:27] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8085)) already shut down 2014-01-12 01:54:27 :: cherrypy.error :: INFO :: [12/Jan/2014:01:54:27] ENGINE No thread running for None. 2014-01-12 01:54:27 :: cherrypy.error :: INFO :: [12/Jan/2014:01:54:27] ENGINE Bus STOPPED 2014-01-12 01:54:27 :: cherrypy.error :: INFO :: [12/Jan/2014:01:54:27] ENGINE Bus EXITING 2014-01-12 01:54:27 :: cherrypy.error :: INFO :: [12/Jan/2014:01:54:27] ENGINE Bus EXITED