Running git-daemon on OS X using startup

I am trying to set up an internal git server using my OS X desktop (mainly as a test case). Everything works when SSH keys are involved, but I'm currently trying to use git -daemon for read-only cloning. If I run git -daemon in a terminal:

sudo -u git git-daemon --basepath=/Users/git/repos/ --export-all 

then everything works fine, for example.

 git clone git://localhost/My_Project.git 

But when I try to install this using start, it refuses all requests. I am using this plist file:

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>git</string> <key>UserName</key> <string>git</string> <key>OnDemand</key> <false/> <key>ProgramArguments</key> <array> <string>/path/to/git-daemon</string> <string>--base-path=/Users/git/repos/</string> <string>--export-all</string> </array> </dict> </plist> 

And get the following error if I try to clone My_Project:

 Cloning into My_Project... fatal: The remote end hung up unexpectedly 

The failure is that I believe this worked, so the problem may be less related to my plist file or using launchd and more for any network settings that can be changed. Any advice would be greatly appreciated.

Sorry if this is more of a sysadmin question, but I thought that the developers might have some experience here.

Update. The console reports the following error if a repo exists:

 git[431] error: cannot run upload-pack: No such file or directory 
+4
source share
2 answers

The problem is that git -demon cannot find the git executable in any of the directories in the PATH that it inherited from the startup process. It works when you start it from your shell, because the PATH inherited from the shell contains the corresponding directory.

Typically, git commands are invoked through the main git command (e.g. git commit , not (more) git-commit ). Among other things, the main git command adds the built-in "exec path" to the PATH environment variable that the "subcommands" inherit.

Your launchd configuration directly calls the "internal" program - git -daemon - instead of allowing the normal top-level program to call it (after the PATH extension, it inherits).

Use the following program parameters:

  <array> <string>/path/to/git</string> <string>daemon</string> <string>--base-path=/Users/git/repos/</string> <string>--export-all</string> </array> 

where /path/to/git is any which git report in your regular shell session.

+6
source

You do not say that he ran. Try taking out OnDemand and add this:

 <key>KeepAlive</key> <true/> <key>RunAtLoad</key> <true/> 

Alternatively, you can use the inetdCompatibility flag (see also: Sockets ) and git-daemon --inetd so that the process only starts when it connects. This will probably be the best configuration for you, although perhaps a little more work to go.

The launchd.plist (5) page has all the details.

0
source

Source: https://habr.com/ru/post/1344744/


All Articles