Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Jan 2013 08:47:07 +0100
From:      =?UTF-8?B?SmF2aWVyIE1hcnTDrW4gUnVlZGE=?= <jmrueda@diatel.upm.es>
To:        freebsd-ports@freebsd.org
Subject:   Re: How to launch services that do not fork to background using the rc infrastructure?
Message-ID:  <5100E6FB.6030905@diatel.upm.es>
In-Reply-To: <50FEB1FE.3030709@FreeBSD.org>
References:  <50FEAE0D.5090505@diatel.upm.es> <50FEB055.8080601@roorback.net> <50FEB1FE.3030709@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 22/01/13 16:36, Greg Larkin wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 1/22/13 10:29 AM, Grzegorz Blach wrote:
>> On 01/22/2013 04:19 PM, Javier Mart■n Rueda wrote:
>>> The typical and simple rc.d script to launch a service has,
>>> esentially, the following:
>>>
>>> . /etc/rc.subr
>>>
>>> name=SERVICE rcvar=SERVICE_enable
>>>
>>> command="/usr/local/sbin/PROGRAM"
>>>
>>> pidfile=/var/run/${name}.pid
>>> SERVICE_enable=${SERVICE_enable:-"NO"}
>>>
>>> load_rc_config ${name} run_rc_command "$1"
>>>
>>> One of the ports (net/spread4) runs a PROGRAM that does not fork
>>> to background as a daemon and which does not have any
>>> command-line option to ask it to do so. Therefore, the rc.d
>>> script never finishes, with various consequences (system boot
>>> stops, no pid file generated...)
>>>
>>> I tried adding a "&" to SERVICE_flags to see if it made it run in
>>> the background, but it didn't do the trick. I also quickly
>>> checked the /etc/rc.subr code to see if there is any way of
>>> forcing a background launch, but couldn't see anything. No luck
>>> searching the web or problem reports either.
>>>
>>> So, my question is whether there is a non-obvious way of forcing
>>> a program to start in background using the rc infrastructure.
>>>
>>
>> Try  command="/usr/sbin/daemon -c -f -p $pidfile PROGRAM" or some
>> thing like this.
>>
> Here's a full example of that in the ViewVC rc.d script:
>
> http://svnweb.freebsd.org/ports/head/devel/viewvc/files/viewvc.in?revision=300896&view=markup
>
> Hope it helps,
> Greg
> - -- 
> Greg Larkin
>
> http://www.FreeBSD.org/           - The Power To Serve
> http://www.sourcehosting.net/     - Ready. Set. Code.
> http://twitter.com/cpucycle/      - Follow you, follow me
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.13 (Darwin)
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iEYEARECAAYFAlD+sf4ACgkQ0sRouByUApAdBgCfdwmbfCokv0Rxm50pTaqZkAkF
> BGoAnjl27+rGvyV3DP4W5rsphL2dbZBd
> =Vi59
> -----END PGP SIGNATURE-----
> _______________________________________________
> freebsd-ports@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-ports
> To unsubscribe, send any mail to "freebsd-ports-unsubscribe@freebsd.org"
Thank you all for your suggestions. In the end I chose to follow the 
viewvc example, and I just submitted an update to the port.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5100E6FB.6030905>