Created
June 3, 2009 04:25
-
-
Save gordonbisnor/122786 to your computer and use it in GitHub Desktop.
Rakefile for Sinatra, Thin, Webfaction
This file contains 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
require 'rake' | |
namespace :thin do | |
desc "Start The Application" | |
task :start do | |
puts "Restarting The Application..." | |
system("thin -s 1 -C config/config.yml -R config/config.ru start") | |
end | |
desc "Stop The Application" | |
task :stop do | |
puts "Stopping The Application..." | |
Dir.new("/home/me/webapps/myapp/tmp/pids").each do |file| | |
Thread.new do | |
prefix = file.to_s | |
if prefix[0, 4] == 'thin' | |
str = "thin stop -Ptmp/pids/#{file}" | |
puts "Stopping server on port #{file[/\d+/]}..." | |
system(str) | |
end | |
end | |
end | |
end | |
desc "Restart The Application" | |
task :restart do | |
puts "Restarting The Application..." | |
[:stop, :start] | |
end | |
end | |
task :deploy do | |
puts "Deploying to server" | |
system("rsync --exclude 'db/myapp.sqlite3.db' --exclude 'tmp/**/*' -rltvz -e ssh . me@mydomain.com:/home/me/webapps/myapp") | |
require 'net/ssh' | |
Net::SSH.start('mydomain.com', 'my user name', :password => "my password") do |ssh| | |
ssh.exec "cd /home/me/webapps/myapp && rake thin:restart" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment