Score:1

My systemd service with type as notify doesn't start when the server goes to stand by starts up again

in flag

The first time I set up my systemd service, it works fine.

However, when I restart the server, the systemd service doesn't start, but it remains on activating.

Could someone give any tip of why this is happening?

Unit file:

[Unit]
Description=My App
After=network.service
StopWhenUnneeded=yes

[Service]
Type=notify
NotifyAccess=all
User=ubuntu
Group=ubuntu

WorkingDirectory=/opt/app
KillMode=process
PIDFile=/tmp/app%I.pid
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=app%I
Environment=SOCKET=/tmp/thin-%I.socket
ExecStart=/opt/app/bin/start
ExecReload=/opt/app/bin/reload
ExecStop=/opt/app/bin/stop
Restart=always
LimitNOFILE=10240
CPUQuota=90%

[Install]
WantedBy=app.target

Logs from journalctl -xe:

Nov 10 20:51:35 hostname systemd[1]: [email protected]: Start operation timed out. Terminating.
Nov 10 20:51:35 hostname systemd[1]: [email protected]: Failed with result 'timeout'.
Nov 10 20:51:35 hostname systemd[1]: Failed to start My App.
-- Subject: Unit [email protected] has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit [email protected] has failed.
--
-- The result is RESULT.
Nov 10 20:51:35 hostname systemd[1]: [email protected]: Service hold-off time over, scheduling restart.
Nov 10 20:51:35 hostname systemd[1]: [email protected]: Scheduled restart job, restart counter is at 4.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Automatic restarting of the unit [email protected] has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Nov 10 20:51:35 hostname systemd[1]: Stopped My App.
-- Subject: Unit [email protected] has finished shutting down
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit [email protected] has finished shutting down.
Nov 10 20:51:35 hostname systemd[1]: Starting My App...
-- Subject: Unit [email protected] has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit [email protected] has begun starting up.

I'm not sure what information I can provide here to help you help me. If I can provide anything, you can ask me in the comments, please.

in flag
Your unit file would be a start. It's status and logs as well.
Sidney avatar
in flag
I've updated the question with more details.
Score:1
in flag

I found out what was happening.

The App needed more time to start, but systemd was always killing it before it had time to start and notify. It only happens when booting because the App takes more time to start when the system is booting.

So I needed to add a larger TimeoutSec, then it worked fine.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.