From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96075320706543.tru64-unix-managers.marc@archive.invalid> From: Hubert Ulliac - Universite de Haute Bretagne Date: Fri, 16 Jun 1995 10:46:39 +0000 To: tru64-unix-managers Subject: SUMMARY: Applications startup X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96075320706543 Bonjour, Firts, thanks to all the people who took their time to reply ! My original post : >What's the best solution for starting applications on Dec Unix ? Three solutions were suggested : 1) >put a script in /sbin/init.d, with a link to it in >/sbin/rc3.d (assuming the application is only to start in >multi-user mode).The links in /sbin/rc3.d (or the scripts they >point to) are executed in ascending numeric order. So for instance >you might make a script /sbin/init.d/test which starts your >application, with a link at /sbin/rc3.d/S97test > >"Some applications will not start this way (they exit with the >startup script). If this happens, the only solution I have found >which works consistently is to create another (trivial) script >to start the application, which the first script submits as an >"at" request. For instance, your /sbin/init.d/test script >might contain > at now + 1 minute /sbin/init.d/start-test" > The files that start with 'S*' are invoked at system boot. > Files with 'K*' are invoked during system shutdown. >-------------------- http://www.fys.ruu.nl/~mos ------------------- > >#!/sbin/sh ># ># Script to start httpd daemon > >PATH=/sbin:/usr/sbin:/usr/bin >export PATH > >case "$1" in >'start') > set `who -r` > if [ "$9" = "S" ]; then > if [ -f /usr/adm/httpd/httpd ]; then > /usr/adm/httpd/httpd -d /usr/adm/httpd > echo "httpd daemon started" > else > echo "Unable to start httpd" > exit 1 > fi > else > echo "Unable to start httpd, Run level must be S" > exit 1 > fi > ;; >'restart') > echo "No restart option available for httpd" > ;; >*) > echo "usage: $0 {start|stop|restart}" > ;; >esac >Create a file called /sbin/init.d/local and put your local command >there. It should look like: > >#!/sbin/sh > >set `who -r` >if [ "$9" != "S" ] >then > exit >fi > ># ># start up httpd server ># >/usr/local/etc/httpd/httpd -d /usr/local/etc/httpd ># ># start up the phmail server ># >nohup /usr/local/nameserv/phmail >/dev/null 2>&1 & >I use one link: > >/sbin/rc3.d/S94systartup -> /usr/local/systartup/ > >and the script has things like > > if [ -f /usr/local/bin/httpd/httpd ]; then > /usr/local/bin/httpd/httpd -d /usr/local/bin/httpd > fi >I have a script called httpd in the /sbin/init.d directory : > >Script follows ----------------------------------------------- >#!/bin/sh ># Scrip to control web server, David Bannon, 26-10-94 >#>PATH=/sbin:/usr/sbin:/usr/bin>export PATH >case "$1" in>'start') > if [ -f /disk2/httpd/httpd ] > then > /disk2/httpd/httpd -d /disk2/httpd & > echo "Starting WEB Server" > fi > ;; >'stop') > kill `cat /disk2/httpd/logs/httpd.pid` > ;; >'who') > grep -v 'bc.*.latrobe.edu.au' /disk2/httpd/logs/access_log | more > ;; >'error') > cat /disk2/httpd/logs/error_log > ;; >*) > echo "usage: httpd {start|stop}" > ;; >esac >--------------------------------------------- Script ends. cstrmr@staffs.ac.uk kleemann@informatik.uni-wuerzburg.de rjackson@gmu.edu stellr@smyrna.cc.vt.edu tom@silverlock.dgim.doc.ca H.J.Mos@fys.ruu.nl magali@lune.lirmm.fr SLOANE@KUHUB.CC.UKANS.EDU gomide@fapq.fapesp.br rockwel@rch.dec.com gunther@vivid.com carole@callutheran.edu D.Bannon@latrobe.edu.au zim@cygne.lbs.cnrs-gif.fr 2) >The respawn parameter causes initd to restart an application as soon as it >exits. If "test" is a script that fires up httpd and then exits, initd will >instantly run it again--even though httpd is still running. > >There are two solutions--one is to only use respawn on an actual >application. Note that this doesn't work on an application that daemonizes >itself. > >http:3:respawn:/usr/local/http/httpd > >If the application daemonizes itself (ie, you get returned to the command >line without putting '&' at the end of the program name), then you have to >use the "once" parameter. You'll also have to figure out another way to get >the app restarted if it dies. > >http:3:once:/usr/local/http/httpd > >If you want to use a script, then either use the "once" parameter or make >sure the script never exits (and make it responsible for restarting the >application): > >test:3:respawn:/usr/local/test > >test: >#!/bin/sh ># ># run httpd and restart it if it exits > >while 1 >do > cd /usr/local/http > httpd > # if we get here we've exited httpd > # pause for a few seconds to let everything recover > sleep 15 >done >Change tht to: > >test:3:once:/usr/local/test >These daemons, typically fork (perhaps a couple of times), and then let the >parent exit. The respawn directive is not appropriate in cases like this. BEEBE@BIOMED.MED.YALE.EDU steve@aztech.com KatzL@msgate.gseps.com nicolis@celfi.phys.univ-tours.fr KatzL@msgate.gseps.com 3) >For an application such as "httpd", that should be executed through the use of >'inetd'. To properly setup 'httpd' is to put an entry in both your >"/etc/services" >and "/etc/inetd.conf" files. > >"/etc/services" > >http 80/tcp # httpd server (World Wide Web tool) > >"/etc/inetd.conf" > >http stream tcp nowait httpu /usr/local/bin/httpd httpd > > >For an application such as "AF", that should be started in "/sbin/rc2" or >"/sbin/rc3" >along with the other applications. winger@sewp.nasa.gov Et encore merci ` tous ------------------------------------------------------------------------------- Hubert ULLLIAC ! Telephone: (33) 99 33 52 79 Universite de Haute Bretagne ! Telecopie: (33) 99 33 52 73 Centre de Ressources Informatiques ! 6 Avenue Gaston Berger ! F-35043 RENNES Cedex ! E-Mail : Hubert.Ulliac@Uhb.Fr -------------------------------------------------------------------------------