Sha256: 088d264e22a1748e9dede6bd9d0050871b5633134ec1717eb10b214e90f956ba

Contents?: true

Size: 1.98 KB

Versions: 11

Compression:

Stored size: 1.98 KB

Contents

#!/bin/bash

# <%= "Start or stop #{fetch(:application)}-sidekiq" %>
#
# <%= fetch(:daemon_author_name) %>

### BEGIN INIT INFO
# Provides:          <%= "#{fetch(:application)}-sidekiq" %>
# Required-Start:    $local_fs $remote_fs $syslog $network
# Required-Stop:     $local_fs $remote_fs $syslog $network
# Should-Start:
# Should-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: <%= "Starts #{fetch(:application)}-sidekiq" %>
# Description:       <%= "Launches #{fetch(:application)}-sidekiq" %>
### END INIT INFO

PATH=/home/maintainer/.rbenv/shims:/home/maintainer/.rbenv/bin:$PATH
PIDFILE=<%= "#{shared_path}/pids/sidekiq.pid" %>
export RAILS_ENV=production

getPID() {
  if [ ! -z `cat $PIDFILE 2> /dev/null` ]; then
    if [[ ! -z $(ps -ef | grep -w `cat $PIDFILE` | grep -v grep) ]]; then
      echo `cat $PIDFILE 2> /dev/null`
    fi
  fi
}

case "$1" in
  start)
    echo -ne "<%= "Starting #{fetch(:application)}-sidekiq..." %>"

    if [ -z "$(getPID)" ]; then
      cd <%=current_path%>
      bundle exec sidekiq -d -v -c <%= fetch(:sidekiq_threads_quantity, 4) %> -g <%= fetch(:sidekiq_queue_label, fetch(:sidekiq_queue_name, fetch(:application))) %> -q <%= fetch(:sidekiq_queue_name, fetch(:application)) %> -P $PIDFILE -e $RAILS_ENV -L <%= "#{shared_path}/log/sidekiq.log" %>

      echo "started!"
    else
      echo "is already running!"
    fi
    ;;

  stop)
    echo -ne "<%= "Stopping #{fetch(:application)}-sidekiq..." %>"

    if [ -z "$(getPID)" ]; then
      echo "is not running!"
    else
      kill -TERM $(getPID) &> /dev/null

      echo "stopped!"
    fi
    ;;

  restart)
    $0 stop
    sleep 3
    $0 start
    ;;

  reject_new_jobs)
    echo -ne "<%= "Rejecting new jobs #{fetch(:application)}-sidekiq..." %>"

    if [ -z "$(getPID)" ]; then
      echo "is not running!"
    else
      kill -USR1 $(getPID) &> /dev/null

      echo "new jobs will be rejected"
    fi
    ;;

  *)
    echo "usage: $0 {start|stop|restart|reject_new_jobs}"
esac
exit 0

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
capistrano-unformatt-1.14.1 vendor/templates/sidekiq.daemon.erb
capistrano-unformatt-1.14 vendor/templates/sidekiq.daemon.erb
capistrano-unformatt-1.13 vendor/templates/sidekiq.daemon.erb
capistrano-unformatt-1.12 vendor/templates/sidekiq.daemon.erb
capistrano-unformatt-1.11 vendor/templates/sidekiq.daemon.erb
capistrano-unformatt-1.10 vendor/templates/sidekiq.daemon.erb
capistrano-unformatt-1.9 vendor/templates/sidekiq.daemon.erb
capistrano-unformatt-1.8 vendor/templates/sidekiq.daemon.erb
capistrano-unformatt-1.7 vendor/templates/sidekiq.daemon.erb
capistrano-unformatt-1.6 vendor/templates/sidekiq.daemon.erb
capistrano-unformatt-1.5 vendor/templates/sidekiq.daemon.erb