F15: Questions re systemd

T.C. Hollingsworth tchollingsworth at gmail.com
Wed Jul 20 00:05:42 UTC 2011


On Mon, Jul 18, 2011 at 1:34 PM, R. G. Newbury <newbury at mandamus.org> wrote:
> New install of F15 on Thinkpad X61. Httpd refuses to start using:
> systemctl enable httpd.service; systemctl start httpd.service

Hmm, this works fine on my installation of F15.  'systemctl enable'
redirects to 'chkconfig' because httpd uses systemd's SYSV
compatibility, but both commands do what you expect.

>
> User:group apache:apache exists and 'owns' /var/www
>
> No httpd.service file was installed through yum. I created one containing:

httpd still uses a SYSV initscript.  systemd is completely compatible
with them for the moment.

> **************************************
> # httpd.service for systemd
> # installed to /lib/systemd/system

Please do not install or edit unit files in /lib/systemd.  Changes in
that directory can be overriden by package updates.  Instead use
/etc/systemd/system, either by creating new unit files in that
directory or copying existing ones in /lib/systemd to /etc and editing
them.  Unit files in /etc/systemd always override identically named
ones in /lib/systemd.

> [Unit]
> Description=httpd daemon
> After=mysqld.service

You probably want "network.target" in After too.  (Although presumably
mysqld has that in its After too.)  If you use NetworkManager and bind
httpd to particular IP addresses also add
"NetworkManager-wait-online.service" to After as well, otherwise it
might come up before it has a socket to bind to.

>
> [Service]
> EnvironmentFile=-/etc/sysconfig/httpd
> ExecStart=/usr/sbin/httpd $OPTIONS -k start
> ExecReload=/usr/sbin/httpd $OPTIONS -k restart
> PIDFile=/run/httpd.pid
> Type=forking

This might be your problem:

> User=apache
> Group=apache

httpd probably needs to be launched as root and allowed to drop
privileges on its own.  (Don't quote me on this though; I don't know
much about the internal workings of httpd.)

One other thing that might affect it:  if you bind httpd to particular
IP addresses, it might require the network to be active

> [Install]
> WantedBy=multi-user.target
> ****************************************
>
> I only get 'Job failed. See system logs and 'systemctl status' for
> details'.  [FAILED]
>
> Status details are no help. I added OPTIONS=" -e 3 -E
> /var/log/httpd/error_log -w" to /etc/sysconfig/httpd, which systemctl
> status says it is executing, but I get NO error_log entries.
>
> Moreover, I get NO systems logs of any sort from systemctl/systemd.
>
> FIRST QUESTION: Where are the system logs?  I do NOT have a
> /var/log/messages file.... Do I need to set a logging option somewhere?

systemd normally logs to syslog.  You really should figure out why
syslog isn't working first.

That being said, you can force systemd to log elsewhere with the
"systemd.log_target=" kernel argument.  Set it to "kmsg" to log to the
kernel message log or "console" to print errors on the console.  You
can also set "systemd.log_level=debug" to get lots more output out of
systemd.  More on these and a lot more at
http://fedoraproject.org/wiki/How_to_debug_Systemd_problems

> SECOND QUESTION: If I use '/usr/sbin/httpd -k start', it works and I get
> httpd threads in the ps list.
> Service httpd status, at that point, says that the start FAILED.
> Service httpd stop does not actually stop anything, nor does systemctl
> httpd.service stop.  (Does not know the pid?)

Exactly.  Systemd has no idea httpd was started, nor does it need to.
It really shouldn't muck about with what the user didn't intend it to
control.

> But another service httpd start, reports that httpd is already running....

That error probably comes from httpd itself, not systemd.

> Does anyone know how to get this working? My google-foo is lacking. I
> can find nothing about where systemd logs data.
> And I can find nothing about whether to remove the original (F14)
> service files.

You don't have to.  systemd unit files will always override
identically named legacy SYSV init scripts.

>              R. Geoffrey Newbury

-T.C.


More information about the users mailing list