peterc (owner)

Fork Of

Revisions

gist: 174396 Download_button fork
public
Public Clone URL: git://gist.github.com/174396.git
Embed All Files: show embed
0what.md #

Poor Man's Deploy

  • Start a Sinatra server on port 4000
  • GET / to that server triggers a git pull and mod_rails restart
  • Hit port 4000 locally after pushing

Why?

We wanted a really, really simple way to deploy Hurl during the 2009 Rails Rumble.

config.ru #
1
2
3
4
5
require 'rubygems'
require 'deployr'
require 'thin'
 
Rack::Handler::Thin.run Deployr.new, :Port => 4000
deployr.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require 'sinatra/base'
 
class Deployr < Sinatra::Base
  get '/' do
    update_hurl
    "ok"
  end
 
  def update_hurl
    return if @running
    @running = true
    Thread.new do
      system "cd /www/hurl/current && git pull origin master && touch tmp/restart.txt"
      @running = false
    end
  end
end
 
Rakefile #
1
2
3
4
5
6
7
task :default => :deploy
 
desc "Sync changes and deploy the app!"
task :deploy do
  `git pull origin master && git push origin master`
  `curl -s http://hurl.r09.railsrumble.com:4000/ &> /dev/null`
end