[DRE-commits] [diaspora-installer] 01/07: fix init script, now start and start works
Praveen Arimbrathodiyil
praveen at moszumanska.debian.org
Thu Dec 25 14:28:25 UTC 2014
This is an automated email from the git hooks/post-receive script.
praveen pushed a commit to branch master
in repository diaspora-installer.
commit 6db3d441413cd5e94597a6c985c11cfea99a5d71
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date: Thu Dec 25 19:24:33 2014 +0530
fix init script, now start and start works
---
debian/diaspora.init | 79 +++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 63 insertions(+), 16 deletions(-)
diff --git a/debian/diaspora.init b/debian/diaspora.init
index 41f3847..c31ffed 100644
--- a/debian/diaspora.init
+++ b/debian/diaspora.init
@@ -17,10 +17,7 @@ DESC="Diaspora application server"
NAME=diaspora
DIASPORA_HOME="/usr/share/diaspora"
-# if you use mySQL:
-# STARTSCRIPT=./script/server
-# if you use postgres use the following line instead
-STARTSCRIPT="export DB=postgres; ./script/server"
+STARTSCRIPT="./script/server"
LOGFILE=$DIASPORA_HOME/log/startscript.log
SCRIPTNAME=$0
@@ -38,6 +35,18 @@ check_sidekiq() {
pgrep -f "sidekiq 2"
}
+check_foreman() {
+ pgrep -f "foreman-runner"
+}
+
+check_foreman_start() {
+ pgrep -f "foreman start"
+}
+
+check_script_server() {
+ pgrep -f "script/server"
+}
+
do_start()
{
if ! touch $LOGFILE; then
@@ -54,10 +63,22 @@ do_start()
log_warning_msg "Diaspora is already running"
return 1
fi
-
- if ! su -l $USER -c "cd $DIASPORA_HOME; $STARTSCRIPT >> $LOGFILE 2>&1 &"; then
+
+ if check_foreman || check_foreman_start || check_script_server; then
+ log_warning_msg "Diaspora is starting"
+ return 1
+ fi
+
+ . /etc/diaspora.conf
+ cd $DIASPORA_HOME
+ sudo -u $USER -E $STARTSCRIPT >> $LOGFILE 2>&1 &
+ if [ $? -gt 0 ]
+ then
log_failure_msg "Could not run start script"
return 2
+ else
+ log_success_msg "Starting diaspora server..."
+ return 0
fi
[ "$VERBOSE" != no ] && log_action_msg "Waiting for Diaspora processes... "
@@ -111,18 +132,44 @@ case "$1" in
status)
log_daemon_msg 'Checking for running Diaspora processes'
- unicorn_running=false
- for i in `check_unicorn`; do
- log_action_msg "Found unicorn master qith PID $i"
- unicorn_running=true
- done
+ if ! check_unicorn
+ then
+ log_action_msg "unicorn not found"
+ unicorn_running=false
+ else
+ for i in `check_unicorn`; do
+ log_action_msg "Found unicorn master with PID $i"
+ unicorn_running=true
+ done
+ fi
- sidekiq_running=false
- for i in `check_sidekiq`; do
- log_action_msg "Found sidekiq with PID $i"
- sidekiq_running=true
- done
+ if ! check_foreman
+ then
+ log_action_msg "foreman not found"
+ foreman_running=false
+ else
+ for i in `check_foreman`; do
+ log_action_msg "Found foreman with pid $i"
+ foreman_running=true
+ done
+ fi
+ if ! check_sidekiq
+ then
+ log_action_msg "sidekiq is not found"
+ sidekiq_running=false
+ else
+ for i in `check_sidekiq`; do
+ log_action_msg "Found sidekiq with PID $i"
+ sidekiq_running=true
+ done
+ fi
+
+ if $foreman_running && ! $unicorn_running; then
+ log_action_msg "Diaspora is starting, check after some time..."
+ log_end_msg 0
+ return 0
+ fi
if $unicorn_running && $sidekiq_running; then
log_action_msg "Diaspora health is OK"
log_end_msg 0
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/diaspora-installer.git
More information about the Pkg-ruby-extras-commits
mailing list