1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Lots of cleanup

This commit is contained in:
Mike Perham 2014-03-09 14:59:55 -07:00
parent ba57fe87cc
commit bbbe318a6c
8 changed files with 14 additions and 114 deletions

View file

@ -1,7 +1,6 @@
# Contributing
First of all, thank you for even opening this file up! I hope you find
it worthwhile to help out with Sidekiq.
First of all, thank you! I hope you find it worthwhile to help out with Sidekiq.
## Issues
@ -21,7 +20,6 @@ fix or new functionality. Functionality must meet my design goals and
vision for the project to be accepted; I would be happy to discuss how
your idea can best fit into Sidekiq.
## Sponsorship
If you've got more money than time and want to sponsor Sidekiq's continued support, your company can buy [Sidekiq Pro](http://sidekiq.org/pro). You get great functionality, I continue to fix bugs and enhance Sidekiq for years to come.

View file

@ -17,14 +17,14 @@ use the Resque client to enqueue jobs in Redis to be processed by Sidekiq.
At the same time, Sidekiq uses multithreading so it is much more memory efficient than
Resque (which forks a new process for every job). You'll find that you might need
50 200MB resque processes to peg your CPU whereas one 300MB Sidekiq process will peg
10 200MB resque processes to peg your CPU whereas one 300MB Sidekiq process will peg
the same CPU and perform the same amount of work.
Requirements
-----------------
I test with the latest Ruby (2.0) and JRuby versions (1.7). Other versions/VMs
I test with the latest Ruby (2.1, 2.0) and JRuby versions (1.7). Other versions/VMs
are untested but might work fine.
The last two major Rails releases (3.2 and 4.0) are officially supported, other

View file

@ -4,7 +4,9 @@
---
:verbose: false
:pidfile: ./tmp/pids/sidekiq.pid
:concurrency: 25
:concurrency: 25
# Set timeout to 8 on Heroku, longer if you manage your own systems.
:timeout: 30
:queues:
- [often, 7]
- [default, 5]

View file

@ -1,6 +1,6 @@
check process sidekiq_myapp
with pidfile /path/to/sidekiq.pid
start program = "bundle exec sidekiq -C /path/to/sidekiq_conf.yml -P /path/to/sidekiq.pid" with timeout 90 seconds
stop program = "kill -s TERM `cat /path/to/sidekiq.pid`" with timeout 90 seconds
if totalmem is greater than 500 MB for 2 cycles then restart # eating up memory?
start program = "bundle exec sidekiq -C /path/to/sidekiq_conf.yml -P /path/to/sidekiq.pid" with timeout 30 seconds
stop program = "kill -s TERM `cat /path/to/sidekiq.pid`" with timeout 30 seconds
if totalmem is greater than 500 MB for 2 cycles then restart # VM bloat is common in Rails apps
group myapp_sidekiq

View file

@ -2,12 +2,12 @@ require 'sidekiq'
# If your client is single-threaded, we just need a single connection in our Redis connection pool
Sidekiq.configure_client do |config|
config.redis = { :namespace => 'x', :size => 1, :url => 'redis://redis.host:1234/14' }
config.redis = { :namespace => 'x', :size => 1 }
end
# Sidekiq server is multi-threaded so our Redis connection pool size defaults to concurrency (-c)
Sidekiq.configure_server do |config|
config.redis = { :namespace => 'x', :url => 'redis://redis.host:1234/14' }
config.redis = { :namespace => 'x' }
end
# Start up sidekiq via

View file

@ -1,100 +0,0 @@
#!/bin/bash
# sidekiq Init script for Sidekiq
# chkconfig: 345 100 75
#
# Description: Starts and Stops Sidekiq message processor for Stratus application.
#
# User-specified exit parameters used in this script:
#
# Exit Code 5 - Incorrect User ID
# Exit Code 6 - Directory not found
#Variable Set
APP="stratus"
APP_DIR="/opt/railsapps/${APP}"
APP_CONFIG="${APP_DIR}/config"
LOG_FILE="$APP_DIR/log/sidekiq.log"
LOCK_FILE="$APP_DIR/${APP}-lock"
PID_FILE="$APP_DIR/${APP}.pid"
GEMFILE="$APP_DIR/Gemfile"
SIDEKIQ="sidekiq"
APP_ENV="production"
BUNDLE="bundle"
START_CMD="$BUNDLE exec $SIDEKIQ -e $APP_ENV -P $PID_FILE"
RETVAL=0
start() {
status
if [ $? -eq 1 ]; then
[ `id -u` == '0' ] || (echo "$SIDEKIQ runs as root only .."; exit 5)
[ -d $APP_DIR ] || (echo "$APP_DIR not found!.. Exiting"; exit 6)
cd $APP_DIR
echo "Starting $SIDEKIQ message processor .. "
$START_CMD >> $LOG_FILE 2>&1 &
RETVAL=$?
#Sleeping for 8 seconds for process to be precisely visible in process table - See status ()
sleep 8
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
return $RETVAL
else
echo "$SIDEKIQ message processor is already running .. "
fi
}
stop() {
echo "Stopping $SIDEKIQ message processor .."
SIG="INT"
kill -$SIG `cat $PID_FILE`
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f $LOCK_FILE
return $RETVAL
}
status() {
ps -ef | egrep 'sidekiq [0-9]+.[0-9]+.[0-9]+' | grep -v grep
return $?
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
while status > /dev/null
do
sleep 0.5
done
start
;;
status)
status
if [ $? -eq 0 ]; then
echo "$SIDEKIQ message processor is running .."
RETVAL=0
else
echo "$SIDEKIQ message processor is stopped .."
RETVAL=1
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 0
;;
esac
exit $RETVAL

View file

@ -43,7 +43,7 @@ Each sidekiq instance is named after its directory, so for an app called `/home/
* The script expects:
* a config file to exist under `config/sidekiq.yml` in your app. E.g.: `/home/apps/my-app/config/sidekiq.yml`.
* a temporary folder to put the processes PIDs exists called `tmp/sidekiq`. E.g.: `/home/apps/my-app/tmp/sidekiq`.
* a temporary folder to put the processes PIDs exists called `tmp/pids`. E.g.: `/home/apps/my-app/tmp/pids`.
You can always change those defaults by editing the scripts.

View file

@ -55,7 +55,7 @@ exec /bin/bash <<EOT
logger -t sidekiq "Starting process: $app-$index"
cd $app
exec bundle exec sidekiq -i ${index} -e production -C config/sidekiq.yml -P tmp/sidekiq/${index}.pid
exec bundle exec sidekiq -i ${index} -e production -C config/sidekiq.yml -P tmp/pids/${index}.pid
EOT
end script
@ -82,6 +82,6 @@ exec /bin/bash <<EOT
logger -t sidekiq "Stopping process: $app-$index"
cd $app
exec bundle exec sidekiqctl stop tmp/sidekiq/${index}.pid
exec bundle exec sidekiqctl stop tmp/pids/${index}.pid
EOT
end script