public
Last active

Create a new project with clockwork for heroku.

  • Download Gist
clockwork-init.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
#!/bin/sh
 
# Licence: MIT
# Created by tomykaira, 2011-10-25
 
if [ $# -ne 1 ]; then
echo "Give me your new project name (only)"
exit 1
fi
 
mkdir $1
if [ $? -ne 0 ]; then
echo "Could not create a new directory"
exit 1
fi
 
cd $1
 
cat > Gemfile <<EOF
source :rubygems
 
gem 'clockwork'
EOF
 
cat > clock.rb <<EOF
require 'rubygems'
require 'clockwork'
include Clockwork
 
handler do |job|
# do something
end
 
every(1.day, 'job_name')
EOF
 
 
echo "/.bundle" > .gitignore
 
echo "clock: bundle exec clockwork clock.rb" > Procfile
 
cat <<EOF
What's next:
 
$ cd $1
$ git init & git add . & git commit
$ bundle install --path bundle/gems
 
Customize clock.rb
 
$ bundle exec clockwork clock.rb
$ heroku create $1 --stack cedar
$ git push heroku master
$ heroku scale clock=1
 
Yah!!
EOF

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.