14

I have a upstart configuration file as shown below which works fine in Ubuntu 14:

#/etc/init/data_server.conf
#sudo start data_server
#sudo stop data_server
#sudo status data_server

start on runlevel [2345]
stop on runlevel [016]

chdir /opt/hold/data_server
respawn

post-start script
    echo "data server started at `date +"%F %T"` on `hostname -f`" | mailx -r "[email protected]" -s "data server Started" "[email protected]"
end script

post-stop script
  sleep 30
end script

limit core unlimited unlimited
limit nofile 100000 100000
setuid goldy
exec ./proc_server --init_file=../config/tree.init --port=8080 --dir=/data/hold/ --max_sec=2400 --max_mb=100 --active=5

Now we are moving to Ubuntu 16 so we can't use upstart and looks like we need to use systemd here. I have to make sure whenever system is rebooted or app is killed it should start my systemd script automatically which in turn start my data server. So I came up with below systemd script: Let me know if this is the right way as I am doing it for the first time?

[Unit]
Description=test server
After=network.target
StartLimitIntervalSec=0

[Service]
User=goldy
Group=goldy
Type=simple
WorkingDirectory=/opt/hold/data_server
ExecStart=/opt/hold/data_server/proc_server --init_file=../config/tree.init --port=8080 --dir=/data/hold/ --max_sec=2400 --max_mb=100 --active=5
Restart=always
RestartSec=3
LimitNOFILE=100000
LimitCORE=infinity

[Install]
WantedBy=multi-user.target

Whenever I run above script, it gives me this error, I am not sure whats wrong?

[/lib/systemd/system/queue_server_two.service:3] Unknown lvalue 'StartLimitIntervalSec' in section 'Unit'

1 Answer 1

23

You are likely comparing systemd docs you've read online for a different version instead using the docs on your system that match your version.

Check man systemd.unit on your own system. You may find that on your version, the directive is named

StartLimitInterval= and should be used [Service], not [Unit].

I found the answer by searching for systemd StartLimitIntervalSec.

7
  • make sense thanks.. also is there any way I can add emailing thing in my systemd script just like I have in upstart? Commented Mar 27, 2018 at 20:50
  • @user1950349 ExecStartPost= Commented Mar 27, 2018 at 21:34
  • systemd syntax doesn't support pipes, so you'll need something like ExecStartPost=/bin/bash -c ''. Then you can put your command back in there as a quoted bash string. As seen in man systemd.unit, you can use %H for the host name, avoiding the call to hostname -f. Commented Mar 28, 2018 at 11:51
  • got it.. so that means this below line should work? Commented Mar 28, 2018 at 19:36
  • 4
    @jamshid man systemd.directives will tell you where any any directive is documented. ` StartLimitIntervalSec=` goes in Unit. The above question is about StartLimitInterval=. By using your local man pages, you can be sure you are checking the docs for the version you are actually running. Commented Aug 8, 2018 at 18:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .