Code

instaweb: restart server if already running
authorStephen Boyd <bebarino@gmail.com>
Mon, 23 Nov 2009 07:09:12 +0000 (23:09 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 24 Nov 2009 05:31:01 +0000 (21:31 -0800)
Running 'git instaweb' when an instaweb server is already running will
fail (at least when the port is the same) and overwrite the pid file
used to track the currently running server. This turns out to be
especially annoying when the user tries to stop the previously running
server with 'git instaweb --stop' and is instead greeted with an error
message because the pid file has been destroyed.

Instead of allowing a user to start two instaweb servers, stop the
currently running server first and then start the new one. This should
be fine because it was never really possible to start two instaweb
servers in the first place due to the pid file issue outlined above.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-instaweb.sh

index d96eddbe56783d61304941a134361797c82480e7..80a7f74feabf7e8c7a72e1e2e6c2f233e7ba5d7c 100755 (executable)
@@ -73,6 +73,11 @@ resolve_full_httpd () {
 }
 
 start_httpd () {
+       if test -f "$fqgitdir/pid"; then
+               say "Instance already running. Restarting..."
+               stop_httpd
+       fi
+
        # here $httpd should have a meaningful value
        resolve_full_httpd