Is there a smart server init script available?

Asked by Mark Crutch

I'm trying to migrate an existing CVS installation to bzr. I would like to run the smart server on one of our hosts, as all the bzr users will be authenticated before they get into our network, so we don't require (or want) the additional authentication of ssh, ftp etc.

During testing everything was fine, as I would ssh into the host, start bzr, then move to a client machine for testing. However now that I've come to deploy it, I can't persuade bzr to run as a smart server unless I maintain an active login. I've tried the following:

* Starting it as a background process, then logging out => bzr is killed when I log out
* Starting it via rc.local => it appears to be running but won't accept any connections
* Starting it via a script in init.d (based on the debian skeleton script in there) => it appears to be running but won't accept any connections
* Starting it via inetd/xinetd => no response from bzr

I'm sure someone must have created a suitable init script, but my google-fu is failing as I keep finding answers for other applications that happen to host their files using bzr. Can anyone point me towards a suitable file, or provide some other clue as to how to successfully run the smart server as a background process on Ubuntu 10.04 LTS.

Question information

Language:
English Edit question
Status:
Solved
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Solved by:
Mark Crutch
Solved:
Last query:
Last reply:
Revision history for this message
Martin Pool (mbp) said :
#1

Hi,

I think the overwhelmingly common thing is to run it over ssh thus it's not shipped with a standalone script.

You shouldn't need any special magic to get it running, so I think the question is why is it not responding when run from eg inetd. Are you running 'bzr serve --inetd'?

Can you try connecting, then finding the bzr process id, then doing 'sudo strace -p PID', and tell us what that says?

Revision history for this message
Mark Crutch (markc-qsiuk) said :
#2

After some further investigation, I believe I have solved this issue, though not without some caveats:

I installed the "inetutils-inetd" package, and edited /etc/inetd.conf to include the following line, straight from the bazaar docs, other than the change of username and repo directory:

4155 stream tcp nowait administrator /usr/bin/bzr /usr/bin/bzr serve --inet --directory=/srv/bzr/

Running netstat -l showed that there was a listening port at 4155, but only with the tcp6 protocol. As we're entirely IP4 based here, I changed the "tcp" entry in inetd.conf to read "tcp4", restarted the service, and am now able to connect. I'm not sure why "tcp" should be defaulting to IP6, but at least it's working now.

I suggest that Canonical should probably update the /etc/services file on Ubuntu to include bazaar on its default port, so that it shows up by name in the netstat output, rather than by port number.

I would still be interested in a mechanism for running bzr from an init script, however. All our other services run that way, and we'd rather use "/etc/init.d/bzr stop|start|restart" simply for consistency. I'll mark this as solved, but if anyone does read it and has any bright ideas, please do comment still.

Revision history for this message
Vincent Ladeuil (vila) said :
#3