2011/8/24 Vitaly Magerya <[email protected]>:
>> the idea to start services concurrently during boot isn't new and the
>> question why FreeBSD doesn't do it has popped up on the forum and
>> mailing list occasionally. So, why not give it a shot?
>
> As someone who uses FreeBSD on hist laptop and is constantly annoyed
> by the lack of suspend-to-disk, every second trimmed of from boot
> time is a win.
>
> In line of the recent FreeBSD problems & solutions discussion, would
> any commiter take time to review and commit this? "FreeBSD 9.1
> introduces concurrent startup, improves boot speed" is the kind of
> buzz we're after.
>
>> Any ideas and feedback are very welcome!
>
> One thing to try is to attach a diagnostics feature that will produce
> data about rc script dependencies and execution times, which can
> be used to visualize which scripts take most time, and how to
> reorganize dependencies to improve boot time (one example I noticed
> is moused: it is only started after network is up, which is a shame,
> since it could easily start while DHCP negotiation is in progress).
Perhaps background_dhclient="YES" should solve it ? I think
background approach (which is current archlinux one [1] ) is not so
bad. It's clearly less powerful than automagic parallelization but
it's maybe less invasive and more flexible for sysadmins.
I gave it a try with a little patch for rc.subr that introduces a
background keyword (eg: moused_enable="background"). It's surly buggy
with some variables like rc_quiet. I have to check more.
[1] https://wiki.archlinux.org/index.php/DAEMONS
Joris
> _______________________________________________
> [email protected] mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "[email protected]"
>
--- /etc/rc.subr 2011-05-02 08:49:11.000000000 +0200
+++ rc.subr 2011-08-25 13:50:29.300275783 +0200
@@ -142,8 +142,9 @@
debug "checkyesno: $1 is set to $_value."
case $_value in
- # "yes", "true", "on", or "1"
- [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+ # "yes", "true", "on", "1", "bg" or "background"
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1|[Bb][Gg]|\
+[Bb][Aa][Cc][Kk][Gg][Rr][Oo][Uu][Nn][Dd])
return 0
;;
@@ -159,6 +160,25 @@
}
#
+# checkbg var
+# Test $1 variable, and return 0 if it's background or bg.
+# Return nonzero otherwise.
+#
+checkbg()
+{
+ eval _value=\$${1}
+ debug "checkbg: $1 is set to $_value."
+ case $_value in
+ [Bb][Gg]|[Bb][Aa][Cc][Kk][Gg][Rr][Oo][Uu][Nn][Dd])
+ return 0
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+}
+
+#
# reverse_list list
# print the list in reverse order
#
@@ -735,54 +755,11 @@
;;
start)
- if [ -z "$rc_fast" -a -n "$rc_pid" ]; then
- echo 1>&2 "${name} already running? (pid=$rc_pid)."
- return 1
+ if checkbg ${rcvar}; then
+ eval _run_rc_start &
+ else
+ _run_rc_start
fi
-
- if [ ! -x ${_chroot}${_chroot:+"/"}${command} ]; then
- warn "run_rc_command: cannot run $command"
- return 1
- fi
-
- if ! _run_rc_precmd; then
- warn "failed precmd routine for ${name}"
- return 1
- fi
-
- # setup the full command to run
- #
- check_startmsgs && echo "Starting ${name}."
- if [ -n "$_chroot" ]; then
- _doit="\
-${_nice:+nice -n $_nice }\
-chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
-$_chroot $command $rc_flags $command_args"
- else
- _doit="\
-${_chdir:+cd $_chdir && }\
-$command $rc_flags $command_args"
- if [ -n "$_user" ]; then
- _doit="su -m $_user -c 'sh -c \"$_doit\"'"
- fi
- if [ -n "$_nice" ]; then
- if [ -z "$_user" ]; then
- _doit="sh -c \"$_doit\""
- fi
- _doit="nice -n $_nice $_doit"
- fi
- fi
-
- # run the full command
- #
- if ! _run_rc_doit "$_doit"; then
- warn "failed to start ${name}"
- return 1
- fi
-
- # finally, run postcmd
- #
- _run_rc_postcmd
;;
stop)
@@ -985,6 +962,59 @@
echo "$_cmd"
}
+_run_rc_start()
+{
+ if [ -z "$rc_fast" -a -n "$rc_pid" ]; then
+ echo 1>&2 "${name} already running? (pid=$rc_pid)."
+ return 1
+ fi
+
+ if [ ! -x ${_chroot}${_chroot:+"/"}${command} ]; then
+ warn "run_rc_command: cannot run $command"
+ return 1
+ fi
+
+ if ! _run_rc_precmd; then
+ warn "failed precmd routine for ${name}"
+ return 1
+ fi
+
+ # setup the full command to run
+ #
+ check_startmsgs && echo "Starting ${name}."
+ if [ -n "$_chroot" ]; then
+ _doit="\
+${_nice:+nice -n $_nice }\
+chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
+$_chroot $command $rc_flags $command_args"
+ else
+ _doit="\
+${_chdir:+cd $_chdir && }\
+$command $rc_flags $command_args"
+ if [ -n "$_user" ]; then
+ _doit="su -m $_user -c 'sh -c \"$_doit\"'"
+ fi
+ if [ -n "$_nice" ]; then
+ if [ -z "$_user" ]; then
+ _doit="sh -c \"$_doit\""
+ fi
+ _doit="nice -n $_nice $_doit"
+ fi
+ fi
+
+ # run the full command
+ #
+ if ! _run_rc_doit "$_doit"; then
+ warn "failed to start ${name}"
+ return 1
+ fi
+
+ # finally, run postcmd
+ #
+ _run_rc_postcmd
+}
+
+
#
# run_rc_script file arg
# Start the script `file' with `arg', and correctly handle the
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[email protected]"