Created
April 26, 2010 13:00
-
-
Save fronx/379294 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pid_path | |
| "~/tmp/pid/" | |
| end | |
| def write_pid(name) | |
| `echo "#{Process.pid}" > #{pid_path}#{name}.pid` | |
| `echo "#{Process.ppid}" > #{pid_path}#{name}.ppid` | |
| end | |
| def delete_pid(name) | |
| `rm -rf #{pid_path}#{name}.pid` | |
| `rm -rf #{pid_path}#{name}.ppid` | |
| end | |
| def pid_task(*args, &block) | |
| task *args do |t| | |
| write_pid(t.name) | |
| block.call | |
| delete_pid(t.name) | |
| end | |
| end | |
| namespace :foo do | |
| pid_task :bar => :environment do | |
| Bla.blub | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| echo "${1} ${2}" | |
| task=$1 | |
| cmd=$2 | |
| case $cmd in | |
| start) | |
| echo $$ > ~/tmp/pid/${task}.pid | |
| rake ${task} | |
| ;; | |
| stop) | |
| kill `cat ~/tmp/pid/${task}.ppid` | |
| kill `cat ~/tmp/pid/${task}.pid` | |
| rm -rf ~/tmp/pid/${task}.* | |
| ;; | |
| *) | |
| echo "usage: rakectl.sh your:task {start|stop}" ;; | |
| esac | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment