From fe97c58222bd5b1837ff2be8e3b44d38708a006d Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Sun, 21 Aug 2016 07:46:53 +0200 Subject: [PATCH] Added upstart script --- upstart/bitmessage.conf | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 upstart/bitmessage.conf diff --git a/upstart/bitmessage.conf b/upstart/bitmessage.conf new file mode 100644 index 00000000..970fd4a7 --- /dev/null +++ b/upstart/bitmessage.conf @@ -0,0 +1,37 @@ +# This is an upstart script for bitmessage for when using daemon mode +# Bitmessage forks more than twice before daemonizing, so a workaround is +# necessary + +description "bitmessage" +author "Peter Surda" + +start on (local-filesystems and net-device-up) +stop on runlevel [!2345] + +setuid bitmessage +setgid bitmessage + +chdir /home/bitmessage +env HOME="/home/bitmessage" + +pre-start script + /usr/src/PyBitmessage/src/bitmessagemain.py +end script + +script + while [ ! -f $HOME/.config/PyBitmessage/singleton.lock ]; do + sleep 1 + done + while [ -f $HOME/.config/PyBitmessage/singleton.lock ]; do + sleep 1 + done +end script + +post-stop script + if [ -f $HOME/.config/PyBitmessage/singleton.lock ]; then + pid=`lsof -F p $HOME/.config/PyBitmessage/singleton.lock|cut -b2-` + if [ -n "$pid" ]; then + kill $pid + fi + fi +end script