summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorGravatar https://www.google.com/accounts/o8/id?id=AItOawmiqeXJtP04fzHOjXs17kHO33v7dWR2xwA <Jaco@web>2013-11-23 08:28:35 +0000
committerGravatar admin <admin@branchable.com>2013-11-23 08:28:35 +0000
commit3431ae88ab5ca12f2b5dad937fa104ff4f5c28ad (patch)
treecee6e6f73e8b73e4244d5a97303087d55e8e104d /doc
parentec8edd25c6917ad10dc129bbaebffdd50afe0d51 (diff)
Added a comment: Init Script
Diffstat (limited to 'doc')
-rw-r--r--doc/forum/webapp_listen_port_with_autostart/comment_2_39664f833dedc1a4fe083eec9bc4a7cd._comment75
1 files changed, 75 insertions, 0 deletions
diff --git a/doc/forum/webapp_listen_port_with_autostart/comment_2_39664f833dedc1a4fe083eec9bc4a7cd._comment b/doc/forum/webapp_listen_port_with_autostart/comment_2_39664f833dedc1a4fe083eec9bc4a7cd._comment
new file mode 100644
index 000000000..0d48ba825
--- /dev/null
+++ b/doc/forum/webapp_listen_port_with_autostart/comment_2_39664f833dedc1a4fe083eec9bc4a7cd._comment
@@ -0,0 +1,75 @@
+[[!comment format=mdwn
+ username="https://www.google.com/accounts/o8/id?id=AItOawmiqeXJtP04fzHOjXs17kHO33v7dWR2xwA"
+ nickname="Jaco"
+ subject="Init Script"
+ date="2013-11-23T08:28:32Z"
+ content="""
+Hi Joey,
+
+Could you help out with writing an init.d script to safely start and stop the webapp on a headless server?
+I made an attempt below based on examples from the internet, but have no idea if it will work.
+
+ #!/bin/bash
+ # git-annex
+ # chkconfig: 345 20 80
+ # description: Git Annex WebApp startup and shutdown script.
+ # processname: git-annex
+
+
+ DAEMON=git-annex webapp
+
+ NAME=git-annex
+ DESC=\"Git Annex WebApp init script\"
+ PIDFILE=/var/run/$NAME.pid
+ SCRIPTNAME=/etc/init.d/$NAME
+
+ case \"$1\" in
+ start)
+ printf \"%-50s\" \"Starting $NAME...\"
+ for dir in $(cat $HOME/.config/git-annex/autostart); do
+ cd $dir
+ PID=`$DAEMON > /dev/null 2>&1 & echo $!`
+ #echo \"Saving PID\" $PID \" to \" $PIDFILE
+ if [ -z $PID ]; then
+ printf \"%s\n\" \"Fail\"
+ else
+ echo $PID > $PIDFILE
+ printf \"%s\n\" \"Ok\"
+ fi
+ done
+ ;;
+ status)
+ printf \"%-50s\" \"Checking $NAME...\"
+ if [ -f $PIDFILE ]; then
+ for PID in $(cat $PIDFILE); do
+ if [ -z \"`ps axf | grep ${PID} | grep -v grep`\" ]; then
+ printf \"%s\n\" \"Process dead but pidfile exists\"
+ else
+ echo \"Running\"
+ fi
+ done
+ else
+ printf \"%s\n\" \"Service not running\"
+ fi
+ ;;
+ stop)
+ printf \"%-50s\" \"Stopping $NAME\"
+ if [ -f $PIDFILE ]; then
+ for PID in $(cat $PIDFILE); do
+ kill -HUP $PID
+ printf \"%s\n\" \"Ok\"
+ done
+ rm -f $PIDFILE
+ else
+ printf \"%s\n\" \"pidfile not found\"
+ fi
+ ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo \"Usage: $0 {status|start|stop|restart}\"
+ exit 1
+ esac
+"""]]