unlink pid file on exit, exec server in ctl script

This commit is contained in:
j 2015-03-07 13:08:26 +05:30
parent 2a7122d7fb
commit 8b23ea9658
2 changed files with 10 additions and 16 deletions

16
ctl
View file

@ -48,9 +48,7 @@ if [ "$1" == "start" ]; then
python3 oml install_update
cd "$BASE/$NAME"
fi
python3 oml server $PID
rm -f $PID
exit $?
exec python3 oml server $PID
fi
if [ "$1" == "debug" ]; then
cd "$BASE/$NAME"
@ -59,8 +57,7 @@ if [ "$1" == "debug" ]; then
exit 1
fi
shift
python3 oml server $@
exit $?
exec python3 oml server $@
fi
if [ "$1" == "stop" ]; then
test -e $PID && kill `cat $PID`
@ -89,8 +86,7 @@ if [ "$1" == "open" ]; then
fi
if [ "$1" == "ui" ]; then
shift
python3 $NAME/oml/ui.py $@
exit $?
exec python3 $NAME/oml/ui.py $@
fi
if [ "$1" == "update" ]; then
cd "$BASE/$NAME"
@ -114,10 +110,8 @@ fi
if [ "$1" == "python" ]; then
cd "$BASE/$NAME"
shift
python3 $@
exit $?
exec python3 $@
fi
cd "$BASE/$NAME"
python3 oml $@
exit $?
exec python3 oml $@

View file

@ -29,7 +29,7 @@ import logging
class MainHandler(OMLHandler):
def get(self, path):
path = os.path.join(settings.static_path, 'html/oml.html')
path = os.path.join(settings.static_path, 'html', 'oml.html')
with open(path) as fd:
content = fd.read()
version = settings.MINOR_VERSION
@ -42,10 +42,8 @@ class MainHandler(OMLHandler):
def run():
setup.create_db()
root_dir = os.path.normpath(os.path.join(os.path.abspath(os.path.dirname(__file__)), '..'))
PID = sys.argv[2] if len(sys.argv) > 2 else None
static_path = os.path.join(root_dir, 'static')
#FORMAT = '%(asctime)-15s %(clientip)s %(user)-8s %(message)s'
#logging.basicConfig(format=FORMAT)
#logger = logging.getLogger('oml.app')
@ -59,8 +57,8 @@ def run():
}
handlers = [
(r'/(favicon.ico)', StaticFileHandler, {'path': static_path}),
(r'/static/(.*)', StaticFileHandler, {'path': static_path}),
(r'/(favicon.ico)', StaticFileHandler, {'path': settings.static_path}),
(r'/static/(.*)', StaticFileHandler, {'path': settings.static_path}),
(r'/(.*)/epub/(.*)', EpubHandler),
(r'/(.*?)/reader/', ReaderHandler),
(r'/(.*?)/pdf/', FileHandler),
@ -116,6 +114,8 @@ def run():
if state.nodes:
state.nodes.join()
http_server.stop()
if PID and os.path.exists(PID):
os.unlink(PID)
signal.signal(signal.SIGTERM, shutdown)