LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-17-2016, 05:53 AM   #1
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,506

Rep: Reputation: 100Reputation: 100
Systemd incorrectly keeps killing a service and restarting it


Hi All

I have the following asterisk.service file in Centos 7 for systemd:

Code:
[Unit]
Description=Asterisk
After=network.target
After=network-online.target
After=startup.service
After=mariadb.service
Wants=mariadb.service

[Service]
Type=forking
User=root
Group=root
ExecStart=/usr/sbin/asterisk -f
ExecStop=/usr/sbin/asterisk -rx 'core stop now'
ExecReload=/usr/sbin/asterisk -rx 'core reload'
TimeoutSec=300

LimitCORE=infinity
LimitNOFILE=8096
Restart=always
RestartSec=4

[Install]
WantedBy=multi-user.target
The problem is that nothing goes wrong with the Asterisk process, but Systemd keeps killing it every 300 seconds and then restarts it.

/var/log/messages contains:

Code:
Feb 17 12:28:43 asterisk systemd: Failed to start Asterisk.
Feb 17 12:28:43 asterisk systemd: Unit asterisk.service entered failed state.
Feb 17 12:28:47 asterisk systemd: asterisk.service holdoff time over, scheduling restart.
Feb 17 12:28:47 asterisk systemd: Stopping Asterisk...
Feb 17 12:28:47 asterisk systemd: Starting Asterisk...
But, in fact, Asterisk DOES get started by systemd, but runs for only the specified 300 seconds. Then systemd kills asterisk, and restarts it.

This continues indefinitely. Asterisk is stable, if I disable the systemd service that starts and monitors and stops it, and start it from the commandline, it runs for hours or even days with no problems.

What is wrong with my asterisk.service file that systemd seemingly does not detect that it is up and is, in fact, running fine?

Thanks

Stefan
 
Old 02-18-2016, 01:49 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
- You set a TimeoutSec covering both shutdown and startup while they may have different values: time a manual service startup and shutdown.
- Your TimeoutSec and RestartSec values are way low.
- 'man systemd.service;' recommends Restart be set to on-failure or on-abnormal.
 
1 members found this post helpful.
Old 02-22-2016, 01:34 AM   #3
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,506

Original Poster
Rep: Reputation: 100Reputation: 100
Hi Guys

Ok, managed to solve this...

My service declaration should have looked like this:

[code]
[Service]
Type=idle
User=root
Group=root
.
.
.
[code]

Once I did the above, Asterisk stayed up and was not killed off every 300 seconds by Systemd.

E. g. I changed
Code:
type=forking
to
Code:
type=idle
Problem solved...!

Stefan

Last edited by rylan76; 02-22-2016 at 01:35 AM.
 
Old 02-22-2016, 01:34 AM   #4
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,506

Original Poster
Rep: Reputation: 100Reputation: 100
unSpawn, thanks for reply - I'll see about extending those timeouts a bit.

Regards

Stefan
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Restarting samba service dahoule Linux - Networking 13 12-11-2012 12:17 PM
[SOLVED] Restarting a Network in Systemd Brandon9000 Linux - General 15 10-24-2012 02:24 PM
Boot Delay 30min: systemd-analyze blame systemd-tmpfiles-setup.service BGHolmes Fedora 0 07-27-2011 10:02 AM
Restarting dns service sandeepthug Linux - Newbie 8 12-17-2008 10:36 AM
Remotely restarting a service seefor Linux - Networking 3 02-15-2007 01:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration