# WARNING: failed to start git_daemon



## c00kie (May 3, 2014)

Hi

I follow this tutorial to the letter: http://bin63.com/how-to-setup-a-git-repository-on-freebsd and edit /etc/rc.conf with:


```
git_daemon_enable="YES"
git_daemon_directory="/git"
#git_daemon_flags="--syslog --base-path=/git --export-all"
git_daemon_flags="--syslog --export-all"
```

Upon `# /usr/local/etc/rc.d/git_daemon start`

```
Starting git_daemon.
/usr/local/etc/rc.d/git_daemon: WARNING: failed to start git_daemon
```

Moreover the boot process hangs at "Starting git_daemon". I pressed ctrl+c and then it finished booting.

Have you had a similar problem or have a quick fix?


----------



## trh411 (May 3, 2014)

Does using `service git_daemon start` give you any additional info?


----------



## c00kie (May 3, 2014)

trh411 said:
			
		

> Does using `service git_daemon start` give you any additional info?



`# service git_daemon start`

```
Starting git_daemon.
```

Go and make a cup of tea...


```
^C
/usr/local/etc/rc.d/git_daemon: WARNING: failed to start git_daemon
```

Are there any logs I need to check?


----------



## trh411 (May 3, 2014)

/var/log/messages would be the first one I'd check?


----------



## c00kie (May 4, 2014)

trh411 said:
			
		

> /var/log/messages would be the first one I'd check?



`# tail /var/log/messages`

```
May  3 14:06:53 web root: /etc/rc: WARNING: failed to start git_daemon
```

Doesn't reveal anything either?


----------



## trh411 (May 4, 2014)

I have devel/git installed, but I've never run the daemon. Based on your problem, I tried starting git_daemon on my system. It fired right up and ran for an hour without incident before I stopped it. 

Try commenting out every git-related statement in /etc/rc.conf except the git_daemon_enable statement and then try to start it using `service git_daemon start`.


----------



## trh411 (May 4, 2014)

Also, please provide the output of `pkg info git`. I'd like to compare your installation options with mine.


----------



## c00kie (May 4, 2014)

That's interesting, in /etc/rc.conf commenting out:

```
git_daemon_enable="YES"
#git_daemon_directory="/git"
#git_daemon_flags="--syslog --export-all"
```

and rebooting the server, the server now boots-up where it failed previously. Moreover:

`# service git_daemon start`

```
git_daemon already running? (pid=1531).
```

`pkg_info` (amongst many other ports) reveals:


```
git-1.9.2           Distributed source code management tool
```

although

`# pkg_info git` reveals:


```
pkg_info: can't find package 'git' installed or in a file!
```

I'm unsure if this is a typo?


----------



## kpa (May 4, 2014)

The old pkg_* tools require a full package name with the version number included. To work around that you can use the -x flag:

`pkg_info -x git`


----------



## c00kie (May 4, 2014)

Ah...OK, the full

`# pkg_info -x git`

```
Information for git-1.9.2:

Comment:
Distributed source code management tool


Description:
Git is a free and open source distributed version control system designed to
handle everything from small to very large projects with speed and efficiency.

WWW: http://git-scm.com/
```

It would appear git is healthy.


----------



## trh411 (May 4, 2014)

c00kie said:
			
		

> That's interesting, in /etc/rc.conf commenting out:
> 
> ```
> git_daemon_enable="YES"
> ...


This makes sense. Commenting out the extra devel/git related statements in /etc/rc.conf has allowed git_daemon to start at boot as desired. Manually running `service git_daemon start` after git_daemon was already started at reboot should generate git_daemon already running? (pid=1531). This is expected.

Now, the question is why the commented out statements result in a "failed to start git_daemon". I would suggest un-commenting them one at a time to find the statement which causes the problem.


----------



## c00kie (May 5, 2014)

Thanks for the help. I think the daemon is running fine now. I'm not completely home and dry with the set-up just yet however.

`# git push origin master`

```
ssh: connect to host web.mydomain.co.uk port 22: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
```

The repository exists:

`# mkdir ~/test`
`cd ~/test && git init`

```
echo 'test' > test
git add .
git commit -m 'test commit'
```

SSH keys exist in /root/.ssh

```
id_rsa		id_rsa.pub
```

Well port 22 is closed by my firewall to prevent library attacks. SSH is open - on another port. Do you know how to set git up to look for another port?


----------



## trh411 (May 5, 2014)

c00kie said:
			
		

> Well port 22 is closed by my firewall to prevent library attacks. SSH is open - on another port. Do you know how to set git up to look for another port?


Check out git-daemon(1). There is a --port option that may be what you need, although that would require modifying ./rc.d/git_daemon. I'm poking about to see if there is a way to set the port in /etc/rc.conf as well. I found DEFAULT_GIT_PORT, but don't know if FreeBSD will recognize that.


----------

