amuck-landowner

Apache on Centos 7 - what is -DFOREGROUND ?

raindog308

vpsBoard Premium Member
Moderator
I yum'd httpd on a new Centos 7 box and when I did a ps (after systemctl start), I see


httpd -DFOREGROUND
What is that?

If I change this in httpd.service:


Code:
[Service]
#Type=notify
Type=forking
#ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
ExecStart=/usr/sbin/httpd $OPTIONS

...then it's just normal httpd.  But what is this -DFOREGROUND stuff?

 

To me running something in the foreground is a way to run a daemon without having it go in the background, so you can debug it, error messages print to the terminal, and you can kill it easily.  It would never be something that I'd choose as a default for a daemon...but I'm probably misunderstanding -DFOREGROUND.  Alas, Google did not help.

 

I would also like to take this opportunity to say how much systemd sucks.  Thank you.

 
 

zzrok

New Member
Systemd is designed to run processes "in the foreground", that is, they don't have to specifically run themselves as daemons.  The processes don't exactly run in the foreground, they run under systemd and it captures their input and output, but from the process's perspective, it is the same as running in the foreground.  That is systemd's preferred method of operation, but it does have compatibility with traditional daemons.
 

raindog308

vpsBoard Premium Member
Moderator
That makes sense.  Well, in the sense that anything about systemd makes sense  :lol:
 

Abdussamad

New Member
That foreground option is also used with docker. You always need a foreground process running in a docker instance. The normal apache way is to fork a background process and that causes docker to shutdown the instance. So you use either this -D FOREGROUND option or a separate program that manages daemons and keeps the container running.
 
Last edited by a moderator:
Top
amuck-landowner