Sha256: eae7cb304f0485a2a91219412d809e4e1244059f714861562e56b16a01a79aa5

Contents?: true

Size: 1.67 KB

Versions: 136

Compression:

Stored size: 1.67 KB

Contents

# Author: Riley Shott
# https://gist.github.com/Ginja/fb123759d48b04b5f338
# dynflow-executor - starts or stops the Dynflow executor for Foreman tasks
#
# chkconfig:   345 99 20
# description: dynflow-executor is a rake task that comes with \
#              the foreman-tasks gem
# processname: dynflow-executor
# pidfile:     /usr/local/foreman/tmp/pids/dynflow_executor_monitor.pid
# pidfile:     /usr/local/foreman/tmp/pids/dynflow_executor.pid

# Source function library.
. /etc/rc.d/init.d/functions

foreman_user='foreman'
rvm='/usr/local/.rvm/bin/rvm'
gemset='ruby-2.1.5@foreman-1.9.1'
foreman_app_path='/usr/local/foreman'
dynflow_executor="$(cd $foreman_app_path && $rvm $gemset do bundle show foreman-tasks)/bin/dynflow-executor"
rvm_do_dynflow="RAILS_ENV=production ${rvm} ${gemset} do ${dynflow_executor}"
prog=$(basename $dynflow_executor)

[ -f /etc/sysconfig/dynflow-executor ] && . /etc/sysconfig/dynflow-executor

start() {
  [ -x $dynflow_executor ] || exit 5
  echo -n $"Starting $prog: "
  su - $foreman_user -c "cd ${foreman_app_path} && ${rvm_do_dynflow} start"
  RETVAL=$?
  if [ $RETVAL -eq 0 ]
    then success
    else failure
  fi
  echo
  return $RETVAL
}

stop() {
  echo -n $"Stopping $prog: "
  cd "${foreman_app_path}"
  su - $foreman_user -c "cd ${foreman_app_path} && ${rvm_do_dynflow} stop"
  RETVAL=$?
  if [ $RETVAL -eq 0 ]
    then success
    else failure
  fi
  echo
  return $RETVAL
}

status() {
  pgrep -f -u $foreman_user dynflow_executor -l
}

restart() {
  stop
  sleep 2
  start
}

case "$1" in
  start)
    $1
    ;;
  stop)
    $1
    ;;
  status)
    $1
    ;;
  restart)
    $1
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart}"
    exit 2
esac

Version data entries

136 entries across 136 versions & 1 rubygems

Version Path
foreman-tasks-0.10.1 extra/dynflow-executor.example
foreman-tasks-0.9.5 extra/dynflow-executor.example
foreman-tasks-0.10.0 extra/dynflow-executor.example
foreman-tasks-0.9.4 extra/dynflow-executor.example
foreman-tasks-0.9.3 extra/dynflow-executor.example
foreman-tasks-0.9.2 extra/dynflow-executor.example
foreman-tasks-0.9.1 extra/dynflow-executor.example
foreman-tasks-0.9.0 extra/dynflow-executor.example
foreman-tasks-0.8.6 extra/dynflow-executor.example
foreman-tasks-0.8.5 extra/dynflow-executor.example
foreman-tasks-0.8.4 extra/dynflow-executor.example
foreman-tasks-0.8.3 extra/dynflow-executor.example
foreman-tasks-0.8.2 extra/dynflow-executor.example
foreman-tasks-0.8.1 extra/dynflow-executor.example
foreman-tasks-0.8.0 extra/dynflow-executor.example
foreman-tasks-0.7.20 extra/dynflow-executor.example