|
OpenBSD Packages and Ports Installation and upgrading of packages and ports on OpenBSD. |
|
Thread Tools | Display Modes |
|
|||
Nginx - autostart & gracefully shutdown
hi friends,
right now, my nginx need to manually start using Code:
$ sudo nginx what is the best practice or suggestion for starting it automatically and able to gracefully shutdown if it detect a power shutdown event (eg, when user press the [POWER] button on their PC) is it by adding pkg_scripts="nginx" using /etc/rc.conf.local ? |
|
|||
Quote:
|
|
|||
thanks to jggimi & ocicat,
i just wanna to confirm, because there is no mention about this is manual, the rule to autostart for all application is rc.conf.local {whatever application name}_flags="" and add them in pkg_scripts if abc_flags="-u root -p 1234567" it would be execute as # abc -u root -p 1234567 during auto start? am i correct? maybe i am confuse about the idea of flags & parameters, |
|
|||
sorry, because English is not my native language,
thanks for the explanation jggimi, so, pkg_scripts would call "executable" that only available & located in /etc/rc.d/ but *_flags would be base on etc/rc.conf file, if it is not there, then no need to use *_flags, eg, php_fpm since there is no mentioned of php_fpm in rc.conf, then to autostart it, we only need to pkg_scripts="php_fpm" no need php_fpm_flags="" and since nginx_flags="" is mentioned in rc.conf, so to use it, we must put nginx_flags="" rc.conf.local but why mysqld_flags="" or pgsql_flags? i am confuse, is that anything that in pkg_scripts must have equivalent *_flags="" entry? i just tried the following, php_fpm_flags=NO so php stop autoboot after a reboot, then this bring another question? isn't it php_fpm_flags="" already sufficient to prove that i want to boot this php_fpm thing? then pkg_scripts is duplicating, imo. Last edited by ershiba; 7th January 2013 at 03:44 PM. Reason: update |
|
|||
There may be some confusion about the separation of start up tasks in rc.conf.local. In OpenBSD 5.0 rc_scripts was renamed pkg_scripts
Quote:
Start up scripts for base packages are listed in /etc/rc.conf. I think the intent is to put start up scripts from added packages in pkg_scripts. For example, my rc.conf.local Code:
ntpd_flags="-s" # enabled during install xdm_flags= # enabled during install lpd_flags="" # Start print daemon apmd_flags="-C" # AMD CPU power management pkg_scripts="dbus_daemon avahi_daemon mpd" I additionally installed dbus, avahi and mpd and on my system these are listed in /etc/rc.d/ |
|
||||
Starting with 5.0, *_flags variables were made generic and could include third party daemons. Prior to that point, they were never used with third party ports/packages.
With that change, if any third party script (let us call it <daemon>) in /etc/rc.d requires flags or user to be set, the admin would set <daemon>_flags or <daemon>_user variables in /etc/rc.conf.local. The <daemon> script still requires inclusion in the pkg_scripts variable, so that /etc/rc knows in what order to execute them. Built-in daemons -- those that come with the base OS, and are not installed from the ports/packages system -- are not listed in the pkg_scripts variable. You only need to change the built-in-daemon_flags variable to something other than =NO. Last edited by jggimi; 7th January 2013 at 04:16 PM. Reason: clarity |
|
|||
thanks shep & jggimi,
base on our conversation above, so i conclude, put *_flags="" for every application that in pkg_scripts (seems to be the desired way) regarding pkg_scripts, if the sole idea is for maintain the order to start & shutdown, first_flags="" second_flags="" third_flags="" maybe if the rc.conf.local reader should able to parse the *_flags things in order and export pkg_scripts on its own. imo. |
|
||||
Quote:
Last edited by jggimi; 7th January 2013 at 04:33 PM. Reason: clarity |
|
||||
Think about daemons procedurally:
|
|
|||
If nginx was not a core package and was installed via ports or pkg_add you would have an /etc/rc.conf.local that looked like this
Code:
ntpd_flags="-s" # enabled during install xdm_flags= # enabled during install lpd_flags="" # Start print daemon apmd_flags="-C" # AMD CPU power management pkg_scripts="nginx mpd" Now that nginx is a core package your /etc/rc.conf.local becomes Code:
ntpd_flags="-s" # enabled during install xdm_flags= # enabled during install lpd_flags="" # Start print daemon apmd_flags="-C" # AMD CPU power management nginx_flags="" # Start nginx web server pkg_scripts="mpd" Code:
ntpd_flags="-s" # enabled during install xdm_flags= # enabled during install lpd_flags="" # Start print daemon apmd_flags="-C" # AMD CPU power management nginx_flags="-u" # Start nginx web server chroot disabled pkg_scripts="mpd" Last edited by shep; 7th January 2013 at 05:27 PM. Reason: 1st edit forgot to close last [CODE] tag 2nd edit clarity |
|
|||
Quote:
so, built in daemon (those that not via pkg_add) autostart = daemonname_flags="" (stop) daemon that get into via pkg_add, autostart = use pkg_scripts (stop) unless we got *_flags != "", otherwise we don't need to *_flags="" since it is unnecessary. so, base on the above idea, Code:
mysqld_flags="" psgsql_flags="" php_fpm_flags="" nginx_flags="" Code:
mysqld_flags="--bind-address=127.0.0.1" nginx_flags="-u" i hope i got this idea right this time. am i? |
|
|||
It appears that the /etc/rc and /etc/rc.conf files shipped with OpenBSD 5.2 release did not include the requisite nginx components.
These were not added until Revision 1.402, Sun Aug 26 19:25:19 2012 UTC. Therefore users of the 5.2 release will need to manually launch nginx via /etc/rc.local. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Why do we need password to shutdown the box ? | sw2wolf | FreeBSD General | 3 | 22nd May 2012 04:35 PM |
shutdown message | derf | FreeBSD General | 5 | 14th December 2010 04:57 PM |
openbsd shutdown | phill | OpenBSD General | 3 | 27th October 2009 12:27 PM |
portupgrade messed up my autostart in rc.conf | semtecs | FreeBSD Installation and Upgrading | 6 | 17th March 2009 05:04 PM |
Autostart Xfce | ninjatux | FreeBSD General | 8 | 16th June 2008 06:47 AM |