[Haskell-cafe] How to daemonize a threaded Haskell program?
Vincent Hanquez
tab at snarc.org
Sat Mar 5 21:51:12 CET 2011
On Sat, Mar 05, 2011 at 08:51:59PM +0100, Bas van Dijk wrote:
> Hello,
>
> I like to turn my Haskell program into a unix daemon. One of the steps
> in "daemonizing" a process is to fork it then exit the parent and
> continue with the child. All this is nicely abstracted in
> hdaemonize[1] which internally calls forkProcess[2].
>
> I would also like to use multiple simultaneous threads in my program.
> Unfortunately forkProcess is not supported when running with +RTS -N
> so I can't use hdaemonize.
>
> I understand why it's problematic to fork a process which is in the
> middle of running multiple simultaneous threads. However, in the case
> of a daemon the fork happens in the beginning of the program. So if I
> can manage to create a program that first daemonizes my process then
> starts the Haskell program, all is good.
>
> My current plan is to have a custom Haskell main function which is
> exported using the FFI:
Hi,
Did you alternatively though about daemonizing in your haskell program normally
without using +RTS -N, and exec'ing yourself (using executeFile) with the extra
cmdline +RTS -N options, and also --no-daemon option to avoid re-daemon/exec'ing ?
I think that would be simpler than your current approch.
--
Vincent
More information about the Haskell-Cafe
mailing list