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

Re: init script cannot stop pid process



Mateusz Łukasik <mati75@linuxmint.pl> writes:

> On 12.02.2015 07:57, Chow Loong Jin wrote:
>> On Wed, Feb 11, 2015 at 10:25:38PM +0100, Mateusz Łukasik 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:
>>
>> This is just a shot in the dark, but how about dropping the --daemon parameter,
>> and telling start-stop-daemon to do the backgrounding?
>>
>> Basically...
>>
>>      start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \
>>      --background --exec $DAEMON -- $DARKHTTPD_ROOT $DARKHTTPD_FLAGS || true
>>
>
>
> The simply way is the best. It definitely fix the issue.

man start-stop-daemon has to say this about the --background option:

WARNING: start-stop-daemon cannot check the exit status if the process
fails to execute for any reason. This is a last resort, and is only
meant for programs that either make no sense forking on their own, or
where it's not feasible to add the code for them to do this themselves.

I'd recommend against using it if there are other (better) solutions.
The usual way is creating a subdirectory (like eg. /var/run/darkhttpd)
in the init script start action with the proper owner and permissions,
and have the daemon manage its PID file there.
-- 
Regards,
Feri.


Reply to: