Skip to content

Instantly share code, notes, and snippets.

@cotapon
Forked from deguchi/build.rb
Created February 20, 2013 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cotapon/4993026 to your computer and use it in GitHub Desktop.
Save cotapon/4993026 to your computer and use it in GitHub Desktop.
# original https://gist.github.com/715378
# thanks hakobe!
# Macで動作確認。Windowsの場合、spawnを使うとよいらしい。 参考: https://gist.github.com/325036
require 'webrick'
server = WEBrick::HTTPServer.new({
:DocumentRoot => nil,
:BindAddress => '0.0.0.0',
:Port => 9090
})
['INT', 'TERM'].each {|signal|
Signal.trap(signal){ server.shutdown }
}
last_pid = nil
server.mount_proc("/run") { |req, res|
if last_pid
Process.kill('KILL', last_pid)
end
last_pid = fork do
exec "ti build -p iphone"
end
# system "coffee -o "+Dir.pwd+"/Resources/js/ -c "+Dir.pwd+"/Resources/coffee/"
res["content-type"] = "text/html; charset=utf-8"
res.body = "ok"
}
warn 'starting server at localhost:9090'
server.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment