Skip to content

Instantly share code, notes, and snippets.

View mattsoutherden's full-sized avatar

Matt Southerden mattsoutherden

View GitHub Profile
@mattsoutherden
mattsoutherden / gist:2701324
Created May 15, 2012 12:18
Wait for delayed job to stop
# Run DelayedJob
namespace :delayed_job do
def wait_for_process_to_end(process_name)
run "COUNT=1; until [ $COUNT -eq 0 ]; do COUNT=`ps -ef | grep -v 'ps -ef' | grep -v 'grep' | grep -i '#{process_name}'|wc -l` ; echo 'waiting for #{process_name} to end' ; sleep 2 ; done"
end
desc "Restart the delayed_job process"
task :restart, :roles => :app do
stop
wait_for_process_to_end('delayed_job')
# /home/bob/env
# USER=bob
# PASS=secret
docker run --env-file /home/bob/env -p 80:80 some/image
# Which is equivalent to:
docker run -e USER=bob -e PASS=secret /path/to/file -p 80:80 some/image
def foo([head | *something*]) when head * 2 < *last* do
some return value
end