[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: init script cannot stop pid process



On Wed, Feb 11, 2015 at 1:25 PM, Mateusz Łukasik <mati75@linuxmint.pl> wrote:
> Hello,
>
> I make darkhttpd package and have a small issue.
>
> I prepare init script:
> https://github.com/mati75/darkhttpd/blob/master/debian/init and for run
> script with start parameter is working fine:
>
> www-data  4615  4615  0.0    1  0.1  12456  1548 ?        Ss   22:13 0:00
> /usr/bin/darkhttpd /var/www --daemon --uid www-data --gid www-data --log
> /var/log/darkhttpd/access.log
>
> But with stop and status is some issue:
>
> status all time return:
>
> [FAIL] darkhttpd is not running ... failed!
>
> stop:
>
> [ ok ] Stopping web server: darkhttpd.
>
> and here the point is darkhttpd still works.

This is almost assuredly because darkhttpd is not writing its PID
file. If you fix that, you should be fine.

>
> Next fact is that I don't see anything pid file in /run which should be
> making by init script and I don't know where I make mistake.
>
> darkhttpd can provides pidfile by itself, but where I see that problem:
>
> error: can't create pidfile /var/run/darkhttpd.pid: Permission denied

Permission error tells me that the daemon is dropping root before
writing the PID file, which is not exactly wrong, but causes problems
in this case. Either in the init script, or in the daemon prior to
dropping priveleges, make sure to create the PID file with the correct
priveleges so it can later be written to when darkhttpd is not root.

Simply adding the following in the start action of the init file,
prior to starting the daemon, should do the trick:

    touch "$PIDFILE"
    chown www-data:www-data "$PIDFILE"

Good luck,
--
Cameron Norman


Reply to: