run git-daemon with --detach on windows 7

643 views
Skip to first unread message

apkr...@gmail.com

unread,
Feb 5, 2012, 6:17:37 PM2/5/12
to msy...@googlegroups.com
Hi,

I'm trying to run git-daemon with:

git daemon --export-all --detach path/to/repo

git daemon doesn't start that way, nothing is listening on default port.
It starts ok without --detached flag but then it is attached to console.
I wont to run the daemon as a service basically. Is that possible?

Thanks

Johannes Schindelin

unread,
Feb 5, 2012, 11:59:06 PM2/5/12
to apkr...@gmail.com, msy...@googlegroups.com
Hi,

Have you tried to debug it?

Remember: Git for Windows is a project run by volunteers. And git daemon
in particular was something that was made to run on Windows with a lot of
effort by a volunteer.

So if it does not run for you, I ask that you put in an effort to find out
why it does not and try to fix it. (In the alternative, you could think of
incentives to convince the few volunteers working on Git for Windows -- in
particular git-daemon on Windows -- to fix your issue.)

Hopefully you understand,
Johannes

Erik Faye-Lund

unread,
Feb 6, 2012, 4:33:43 AM2/6/12
to msy...@googlegroups.com

--detach isn't supported on Windows. git-daemon even tells you this
when you try to start it, by outputting "--detach not supported on
this platform" to stderr.

Adding built-in windows-service support to git-daemon isn't
straight-forward. However, I've looked into making a windows-service
wrapper for git-daemon, and it seems quite doable. But then I found
out about SrvAny, and figured that was probably good enough for what
people needs.

Konstantin Khomoutov

unread,
Feb 6, 2012, 8:54:36 AM2/6/12
to kusm...@gmail.com, msy...@googlegroups.com

Or http://nssm.cc/ which is a bit more thorough in its approach to
handling the process it hosts.

Pat Thoyts

unread,
Feb 6, 2012, 6:29:06 PM2/6/12
to kusm...@gmail.com, msy...@googlegroups.com

Hmm. Seems not to print this message for me:

C:\src\git-gui>git daemon --export-all --detach

C:\src\git-gui>git version
git version 1.7.9.msysgit.0

Neither for cmd nor git bash shells.

Erik Faye-Lund

unread,
Feb 6, 2012, 6:35:42 PM2/6/12
to Pat Thoyts, msy...@googlegroups.com

line 1004 of daemon.c says "die("--detach not supported on this
platform");". And I can even step through the code and see that it
gets called. But for some reason the message never appears on the
terminal. Strange.

Erik Faye-Lund

unread,
Feb 6, 2012, 6:43:23 PM2/6/12
to Pat Thoyts, msy...@googlegroups.com

After stepping a little bit, I see what the problem is: --detach
implies --syslog, which calls sets a custom die-routine before trying
to daemonize. So when we try to print errors, they end up in Windows'
application event log instead of on the console.

Which isn't really that strange, and is the same as what happens on
Linux (if an error would occur, that is). But it's certainly not the
most graceful way of erroring out in this case; this is a missing
feature, not a normal run-time error.

Pat Thoyts

unread,
Feb 6, 2012, 6:53:13 PM2/6/12
to kusm...@gmail.com, msy...@googlegroups.com

Ah - I was about to post my tracing too :)
It makes more sense when the platform disallows --detach to avoid
setting the log_syslog flag so that it doesn't divert the messages.
Maybe just the following to die immediately:

diff --git a/daemon.c b/daemon.c
index ab21e66..b11e0b4 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1189,8 +1189,12 @@ int main(int argc, char **argv)
continue;
}
if (!strcmp(arg, "--detach")) {
+#ifdef NO_POSIX_GOODIES
+ die("--detach not supported on this platform");
+#else
detach = 1;
log_syslog = 1;
+#endif
continue;
}
if (!prefixcmp(arg, "--user=")) {

Erik Faye-Lund

unread,
Feb 6, 2012, 6:55:22 PM2/6/12
to Pat Thoyts, msy...@googlegroups.com

Yeah. The reason that wasn't done that way in the first place was that
Junio doesn't like ifdefs inside functions, and we didn't spot this
glitch until now.

Reply all
Reply to author
Forward
0 new messages