If not the force, what should I use? (Was: FreeBSD in Business (was Re: Idea for FreeBSD))

Freddie Cash fjwcash at gmail.com
Thu Aug 14 01:22:34 UTC 2008


On Wed, Aug 13, 2008 at 1:40 AM, Vincent Hoffman <vince at unsane.co.uk> wrote:
> Jonathan McKeown wrote:
>> On Tuesday 12 August 2008 17:51:32 Mike Meyer wrote:
>>> On Tue, 12 Aug 2008 17:10:22 +0200 "Adrian Penisoara"
>>> Ok, given that you 1) want to have both "XXXX this service if it's
>>> part of our normal runtime" and "XXXX this service even if it's not
>>> part of our normal runtime" as script commands, and that 2) XXXX
>>> without a prefix gets the "if it's part of our normal runtime"
>>> meaning, as we want the user to have to explicitly say "Yes, I know
>>> this looks odd, but I know what I'm doing so do it anyway" to get the
>>> "even if it's not part of our normal runtime" behavior, then what
>>> would you have us use instead of "forceXXXX"?
>>>
>> People keep talking about forcestart.
>>
>> Unless I'm misunderstanding things horribly, forcestart does exactly that
>> - forces the service to start regardless of any error that may occur.
>>
>> The better option for starting something as a one-off (not enabled in
>> rc.conf) is mnemonically named onestart - which only ignores the rcvar but
>> still fails on any other error.
>>
>> And yes, I like having onestart/onestop distinguished from start/stop.
>>
> I believe it "forces" a start even though its not actually enabled (in
> rc.conf) rather than regardless of errors.
> If you really want a command line of onestart/onestop install the
> sysutils/bsdadminscripts port which has a script called rconestart and
> rconestop which do exactly that ;)

>From /etc/rc.subr:
# run_rc_command argument
#       Search for argument in the list of supported commands, which is:
#               "start stop restart rcvar status poll ${extra_commands}"
#       If there's a match, run ${argument}_cmd or the default method
#       (see below).
#
#       If argument has a given prefix, then change the operation as follows:
#               Prefix  Operation
#               ------  ---------
#               fast    Skip the pid check, and set rc_fast=yes
#               force   Set ${rcvar} to YES, and set rc_force=yes
#               one     Set ${rcvar} to YES

Further in the file:
        case "$rc_arg" in
        fast*)                          # "fast" prefix; don't check pid
                rc_arg=${rc_arg#fast}
                rc_fast=yes
                ;;
        force*)                         # "force prefix; always run
                rc_force=yes
                _rc_prefix=force
                rc_arg=${rc_arg#${_rc_prefix}}
                if [ -n "${rcvar}" ]; then
                        eval ${rcvar}=YES
                fi
                ;;
        one*)                           # "one" prefix; set ${rcvar}=yes
                _rc_prefix=one
                rc_arg=${rc_arg#${_rc_prefix}}
                if [ -n "${rcvar}" ]; then
                        eval ${rcvar}=YES
                fi
                ;;
        esac

Which, if I follow things, means:
  ** "/etc/rc.d/$script faststart" won't check for existing PID files
or already running apps, and just run $script, but still checks if
$script_enable=yes is in /etc/rc.conf.

  ** "/etc/rc.d/$script onestart" sets $script_enable=yes internally,
regardless of what is in rc.conf, and runs $script.  All other checks
are done as per normal.

  ** "/etc/rc.d/$script forcestart" runs $script, regardless of what's
in rc.conf, the status of the PID file, or the existence of an already
running daemon.

What most people in this thread are looking for is onestart.

-- 
Freddie Cash
fjwcash at gmail.com


More information about the freebsd-hackers mailing list