LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   CentOS (https://www.linuxquestions.org/questions/centos-111/)
-   -   custom systemd httpd service fails to start on centos 7 (https://www.linuxquestions.org/questions/centos-111/custom-systemd-httpd-service-fails-to-start-on-centos-7-a-4175571796/)

mariogarcia 02-09-2016 09:39 AM

custom systemd httpd service fails to start on centos 7
 
I have the following systemctl service
Code:

[Unit]
Description=The Apache HTTP Server for foobar
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)

[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/usr/sbin/httpd -f /etc/httpd/conf.d/httpd.foobar.conf
ExecReload=/usr/sbin/httpd -f /etc/httpd/conf.d/httpd.foobar.conf -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true

[Install]
WantedBy=multi-user.target

the service fails with a timeout:
systemctl status httpd_foobar.service
â httpd_foobar.service - The Apache HTTP Server for foobar
Loaded: loaded (/usr/lib/systemd/system/httpd_foobar.service; disabled; vendor preset: disabled)
Active: failed (Result: timeout) since Tue 2016-02-09 15:52:06 CET; 21min ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 23622 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 23620 ExecStart=/usr/sbin/httpd -f /etc/httpd/conf.d/httpd.foobar.conf (code=exited, status=0/SUCCESS)
Main PID: 23620 (code=exited, status=0/SUCCESS)

Feb 09 15:50:36 web7 systemd[1]: Starting The Apache HTTP Server for foobar...
Feb 09 15:50:36 web7 kill[23622]: kill: cannot find process ""
Feb 09 15:50:36 web7 systemd[1]: httpd_foobar.service: control process exited, code=exited status=1
Feb 09 15:52:06 web7 systemd[1]: httpd_foobar.service stop-sigterm timed out. Killing.
Feb 09 15:52:06 web7 systemd[1]: Failed to start The Apache HTTP Server for foobar.
Feb 09 15:52:06 web7 systemd[1]: Unit httpd_foobar.service entered failed state

is it something related to selinux?

when i restart manually via the command line:
it works but not when trying via systemctl.

ondoho 02-10-2016 12:00 AM

did you write that service file yourself?
have you looked up centos wiki, then apache wiki, then systemd documentation? (*)
if this is apache, are you sure you need httpd to start it? i have a debian server and it doesn't have httpd in $PATH.

(*) archwiki has always been very helpful with systemd

mariogarcia 02-12-2016 08:12 AM

Hello
I wrote the service file based in the one that comes with the rpm. i just changed the ExecStart and Execreload..

i have set up selinux as permissive but the problem is not related to selinux..

I have read the documentation of systemd. centos and apache but I did not find any hints as to whiy systemd hangs out... that Is why I reached out to see if someone has any ideas..

thanks in advance.

ondoho 02-13-2016 02:51 AM

undo that stuff.

try
Code:

# systemctl start apache2
instead (*).

if that works, do
Code:

# systemctl enable apache2
assuming you just want to start your apache server - you never said what you actually want.

(*) at least this is how it works on debian stable. alternatively, i think you can also use apachectl.


All times are GMT -5. The time now is 03:13 AM.