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-2.0.2 extra/dynflow-executor.example
foreman-tasks-1.1.3 extra/dynflow-executor.example
foreman-tasks-1.1.2 extra/dynflow-executor.example
foreman-tasks-2.0.1 extra/dynflow-executor.example
foreman-tasks-2.0.0 extra/dynflow-executor.example
foreman-tasks-1.2.0 extra/dynflow-executor.example
foreman-tasks-1.1.1 extra/dynflow-executor.example
foreman-tasks-1.1.0 extra/dynflow-executor.example
foreman-tasks-0.17.6 extra/dynflow-executor.example
foreman-tasks-1.0.1 extra/dynflow-executor.example
foreman-tasks-1.0.0 extra/dynflow-executor.example
foreman-tasks-0.17.5 extra/dynflow-executor.example
foreman-tasks-0.17.4 extra/dynflow-executor.example
foreman-tasks-0.17.3 extra/dynflow-executor.example
foreman-tasks-0.17.2 extra/dynflow-executor.example
foreman-tasks-0.16.3 extra/dynflow-executor.example
foreman-tasks-0.17.1 extra/dynflow-executor.example
foreman-tasks-0.15.11 extra/dynflow-executor.example
foreman-tasks-0.16.2 extra/dynflow-executor.example
foreman-tasks-0.15.10 extra/dynflow-executor.example