Skip to content
This repository has been archived by the owner on Aug 14, 2018. It is now read-only.

Commit

Permalink
Teach bananajour some basic housekeeping skills.
Browse files Browse the repository at this point in the history
Make sure child processes (Sinatra & git-daemons) are killed on exit.
  • Loading branch information
freshtonic authored and toolmantim committed Nov 9, 2009
1 parent 1eba478 commit 11850f9
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions bin/bananajour
Expand Up @@ -9,13 +9,22 @@ Bananajour.setup! if !Bananajour.setup?
Bananajour.check_git!
Bananajour.check_git_config!

pids = []

["INT", "TERM", "HUP"].each do |sig|
Signal.trap sig do
pids.each{|pid| Process.kill "TERM", pid rescue nil}
exit 0
end
end

case ARGV.first

when nil
Bananajour.serve_web!
Bananajour.serve_git!
Bananajour.advertise!
Process.wait
pids << Bananajour.serve_web!
pids << Bananajour.serve_git!
pids << Bananajour.advertise!
Process.waitall

when "add", "init"
repo = Bananajour.add!(ARGV[1] || File.expand_path("."))
Expand Down

0 comments on commit 11850f9

Please sign in to comment.