Gocd: SystemD init support

Created on 13 Oct 2017  路  6Comments  路  Source: gocd/gocd

Issue Type
  • Feature enhancement
Summary


Debian and Ubuntu use systemd for some time for service management, go still uses initd scripts which are not visible for systemctl and service tool on these systems (or at least on Ubuntu Xenial)

Environment
Basic environment details
  • Go Version: 17.10.0-5380
  • OS: Ubuntu 17.04
Steps to Reproduce


  1. Set up Ubuntu 16.04 vm
  2. Install go-server from deb package
  3. Try to run it by systemctl start go-server
  4. Try to run it by service go-server start
Expected Results

Commands 3 and 4 should start go-server service

Actual Results

Commands fails due to absence of systemd unit(service) file

root@ip-10-0-252-131:~# systemctl start go-server
Failed to start go-server.service: Unit go-server.service not found.
root@ip-10-0-252-131:~# service go-server start
Failed to start go-server.service: Unit go-server.service not found.
root@ip-10-0-252-131:~#
Possible Fix

Write systemd unit file(type forking) which use current initd script commands and look on pid file and bundle it in go-server package

Most helpful comment

I've recently installed GoCD on Debian 9 using the provided .deb package.

After installation, I had to run systemctl daemon-reload for systemd to detect the new initd script shipped with GoCD.
After running this command, the unit file generated by systemd became available. Then I was able to run commands like systemctl start go-server.

A user might not know that reloading the systemd daemon is required. This should have happened as part of the installation of the .deb package itself.

All 6 comments

I've got a simple systemd unit file which works for me with the zip installation in case it helps:

https://github.com/bmaupin/junkpile/blob/master/systemd-services/go-server.service

At the very least the home folder for the binaries will need to be adjusted for the .deb installation.

I've updated the unit file posted here above by bmaupin (thanks for the initial version) with the following:

  • added capabilities so that binding ports <1024 is allowed
  • added stop command
  • added missing parameter "service_mode" when starting the server (ExecStart), with this logs are put under /var/log/go-server/go-server.log and not in the WorkingDirectory.
  • PID file is under /var/run/go-server/go-server.pid

I tested all standard commands (start/stop/restart) and they work. Hope this helps someone else :).

https://github.com/VincenzoDo/go-server-systemd/blob/master/go-server.service

@VincenzoDo Out of curiosity, do you think the stop command is necessary? If all you're doing is killing the process, systemd should be able to handle that itself, right?

@bmaupin If I remember correctly I tested it without the stop command and it wouldn't stop the process automatically, that's why I added it. Also, I think that's due to the fact that when the process starts it actually starts a java process which isn't fully/correctly tracked by systemd.

I've recently installed GoCD on Debian 9 using the provided .deb package.

After installation, I had to run systemctl daemon-reload for systemd to detect the new initd script shipped with GoCD.
After running this command, the unit file generated by systemd became available. Then I was able to run commands like systemctl start go-server.

A user might not know that reloading the systemd daemon is required. This should have happened as part of the installation of the .deb package itself.

Closing. GoCD 19.7.0 and newer support systemd.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rschneiderman39 picture rschneiderman39  路  5Comments

GaneshSPatil picture GaneshSPatil  路  3Comments

yqian1991 picture yqian1991  路  4Comments

arvindsv picture arvindsv  路  6Comments

arvindsv picture arvindsv  路  3Comments