Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

So I wrote a golang app which I want initialized by systemd whenever my server gets a reboot.

Here's the service file:-

[Unit]
Description=golang wiki initialization

[Service]
Type=forking
PIDFile=/tmp/gowiki.pid-3030
User=root
Group=root
WorkingDirectory=/var/www
ExecStart=/bin/bash -c 'daemonize -o stdout.log -e stderr.log /var/www/wiki'

[Install]
WantedBy=multi-user.target

It appears to work well whenever I reboot the server but I am still running into slightly irritating problem when I am manually starting or restarting gowiki like this in terminal:-

systemctl start gowiki

or

systemctl restart gowiki

This does get my gowiki process running; however, after I execute my systemctl start gowiki command, I am frozen in my terminal and the command does not seem to exit until I manually force a Ctrl-C.

What am I doing wrong to be causing this problem?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

This worked.

[Unit]
Description=golang wiki initialization

[Service]
PIDFile=/tmp/gowiki.pid-4040
User=root
Group=root
WorkingDirectory=/var/www
ExecStart=/bin/bash -c '/var/www/wiki'

[Install]
WantedBy=multi-user.target

Because the Type=forking services expect the parent service to exit before the service has actually started. If the parent never exits, then systemctl start will not give you back a prompt because it doesn't think that it's done executing.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.