Closed dbuzz111 closed 5 years ago
Sure, there's a contrib/
directory for init scripts, so if you do a pull request I can have a look at them.
Well from what I can see, the recommendation is to start apache with apachectl start
. But there are sources on the Internet that say you can still start the daemon itself using either one of: httpd -DNO_DETACH
or httpd -DFOREGROUND
. On Debian/Ubuntu they've renamed httpd to apache2, but the same should work.
On Debian you need to set a few environment variables first, see /etc/apache2/apache2.conf, and for that you can use a Finit service wrapper script
Thanks for that. I've read through the material a few times and I guess I am hung up on the pid aspect. If I use; service [S12345 pid:!/var/run/apache2/apache2.pid] /usr/sbin/apachectl start -- Apache Web Server
This will start the process, however it starts it multiple times and I get an error httpd already running in the console.
If I remove the ! I don't seem to get any different result. I've read over the service wrapper doc and the conditions document.
I guess I should have asked the actual question, how do I work with pid's of processes that create their own, and the inverse how do I work with processes that don't create their own pid's. (Should I create the pid via bash?)
I run into this with the cron daemon too, I am pretty sure I am just looking at this backwards somehow.
Thank you very much for your help!
The service
stanza is for supervising/monitoring processes that do not daemonize, or fork to the background. It cannot be used with client tools like apachectl
which, from what I understand at least, is a wrapper to the actual daemon process. Finit currently does not have any means to monitor a process that has been started by someone else. (systemd calls these type of processes "forking")
In your case above Finit will notice apachectl
exiting, interpret that as it's crashing, and thus try to restart it. This will happen up to 10 times before Finit gives up. So that's why you see errors about "httpd already running".
The pid:
setting is currently only as a help to Finit. By default Finit assumes a daemon foo creates its PID file in /var/run/foo.pid
, but some use a sub-directory or a different name, and some daemons don't even bother creating a PID file, in which case Finit can create one. The existence of a PID file is only used by Finit to track conditions between services, e.g. if you want process foo to start after syslogd
you set a condition <svc/sbin/syslogd>
in the service stanza for foo. If you don't have any conditions in your system, then you don't need the PID file handling.
To fix your problem, I'd personally look at how to start apache httpd without apachectl. Possibly from a service wrapper, as I mentioned previously. Something like this perhaps:
/etc/start.d/apache:
#!/bin/sh
APACHE_foo1=bar1
export APACHE_foo1
APACHE_foo2=bar2
export APACHE_foo2
...
exec /usr/sbin/httpd -DFOREGROUND
/etc/finit.d/apache.conf:
service [2345] /etc/start.d/apache -- Apache web server
Of course you'll have to look into the details of what environment variables you need to provide, as well as proper paths etc. This is just pseudo code.
Hello again,
I was wondering if you knew of any distributions actively including this as their main boot loader, or optional boot loader right out of the box?
Thank you very much!
Nope, no big/useful distros that I know of. There are a few companies, however, that rely on it in their products.
Hello there!
Loving this project so much. I wrote a few init scripts for some standard services, would you like me to contribute them?
On that note, any suggestions on the best way to start apache? Strange lame question I know but apache is not ideal for starting via finit.
Thanks!