-
-
Save maxy/776244 to your computer and use it in GitHub Desktop.
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
# 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 | |
coffee_blend = system "coffee -o "+Dir.pwd+"/Resources/ -c "+Dir.pwd+"/Resources/coffee/" | |
if !coffee_blend | |
warn "!!!CoffeeScript compile Error!!!" | |
res["content-type"] = "text/html; charset=utf-8" | |
res.body = "error" | |
else | |
last_pid = fork do | |
exec "/Library/Application Support/Titanium/mobilesdk/osx/1.5.1/iphone/builder.py", "run", Dir.pwd | |
end | |
res["content-type"] = "text/html; charset=utf-8" | |
res.body = "ok" | |
end | |
} | |
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