From 85341ca3c33797da06a9838c36fa70c66bdf515f Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Sat, 16 Feb 2008 14:57:41 +0000 Subject: [PATCH] ActionItem154: finishing initscripts --- etc/init.d/noosfero | 20 ++++++++++++++------ script/production | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 6 deletions(-) create mode 100755 script/production diff --git a/etc/init.d/noosfero b/etc/init.d/noosfero index 9912658..582a728 100644 --- a/etc/init.d/noosfero +++ b/etc/init.d/noosfero @@ -32,14 +32,24 @@ SCRIPTNAME=/etc/init.d/$NAME # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh -if [ -z $NOOSFERO_DIR ]; then - echo "NOOSFERO_DIR not defined, noosfero not being started." +if [ -z $NOOSFERO_DIR ] || [ -z $NOOSFERO_USER ]; then + echo "NOOSFERO_DIR or NOOSFERO_USER not defined, noosfero not being started." + echo "Both variables must be defined in /etc/default/noosfero" exit 0 fi ###################### FERRET_PID_FILE=$NOOSFERO_DIR/log/ferret.pid +main_script() { + cd $NOOSFERO_DIR + if [ "$NOOSFERO_USER" != "$USER" ]; then + su $NOOSFERO_USER -c "./script/production $1" + else + ./script/production $1 + fi +} + do_start() { # FIXME should not test for ferret only @@ -48,8 +58,7 @@ do_start() { exit 2 fi - cd $NOOSFERO_DIR - ./script/production start + main_script start } do_stop() { @@ -60,8 +69,7 @@ do_stop() { exit 2 fi - cd $NOOSFERO_DIR - ./script/production stop + main_script stop } do_restart() { diff --git a/script/production b/script/production new file mode 100755 index 0000000..da9ca1c --- /dev/null +++ b/script/production @@ -0,0 +1,37 @@ +#!/bin/sh + +export RAILS_ENV=production + +ACTION=$1 +shift + +do_start() { + ./script/ferret_start + sleep 1 + mongrel_rails cluster::start + sleep 3 +} + +do_stop() { + mongrel_rails cluster::stop + sleep 1 + ./script/ferret_stop +} + +case "$ACTION" in + start|stop) + do_$ACTION + ;; + + restart) + do_stop + sleep 1 + do_start + ;; + + *) + echo "usage: $0 start|stop|restart" + exit 1 + ;; +esac + -- libgit2 0.21.2