II.d.1 Running as a Detached Process ------------------------------------ Edit the command files [.EXE]START_GOPHER.COM and [.EXE]RUN_GOPHERD_DAEMON.COM as appropriate for your site. If you are running a single server on port 70, and want to accept the default definitions and names for log files, you probably do not have to make any modifications to these files. Notice in the example START_GOPHER.COM below, we use, but do not define, the GOPHER_ROOT logical cited in the example above. It is assumed this logical was defined earlier (normally during system startup). The primary function of the START_GOPHER.COM file is to start a detatched process, the Gopher Server daemon, after defining the one minimum logical which the OpenVMS Gopher Server requires, GOPHER_CONFIG. In the example, this logical uses the data directory defined earlier (GOPHER_ROOT). The GOPHER_RESTART logical, if it exists, is deassigned. This logical may be defined at any time after starting the daemon to cause it to shut down in a graceful manner. The privileges established are the minimum required by the daemon. In the following examples, notice the "70" in filenames and logicals -- this is for convention only, but it identifies the use of port 70 for the server. Servers intended to run on other ports might use a different value. In the example START_GOPHER.COM file, use is made of site-specific directories and rooted logical devices (GOPHER_ROOT:[000000] and GOPHER_EXE). You may of course place them wherever it is appropriate and edit the .COM files accordingly. It is recommended, however, you make these modifications in SETUP_GOPHER.COM, if needed. From START_GOPHER.COM -- $ Define/system Gopher_Config Gopher_Root:[000000]_Gopher70 $ set proc/priv=(detach, sysprv, tmpmbx, netmbx) $ if f$trnlnm("GOPHER_RESTART_70") .nes. "" then - deassign/system GOPHER_RESTART_70 $ run/detach/Proc="Gopher1_Server"- /buffer_limit=140000- /working_set=500/extent=2500/maximum_working_set=1500- /input= GOPHER_EXE:run_gopherd_daemon.com- /output= GOPHER_ROOT:[000000]_output70- /error= GOPHER_ROOT:[000000]_error70 - /priv= (NOSAME, SYSPRV, TMPMBX, NETMBX) - Sys$System:Loginout The DCL to run the Gopher Server daemon establishes privileges, cleans up the log files produced by prior runs of the daemon, and then invokes the GopherD executable. In the example RUN_GOPHERD_DAEMON.COM file, this executable has been located in a site-specific directory with the RUN_GOPHERD_DAEMON.COM file (GOPHER_EXE, defined in SETUP_GOPHER.COM). You may of course place them wherever it is appropriate and edit the .COM files accordingly. Add invocation of the editted command file START_GOPHER.COM to your system startup, on the node where the server daemon is going to run. Invoke by a SUBMIT/USER=GOPHERD, where GOPHERD has been defined in your UAF as a user with only batch access and the required privileges. The daemon discards sysprv as soon as it has bound to the TCP/IP port (sysprv is required by many TCP/IP agents for binding to ports < 100). If desired, further analysis of the logical GOPHER_RESTART_70 might be done after the daemon exits, perhaps causing the procedure to loop back and start over again (see the example RUN_GOPHERD_DAEMON.COM file supplied). From RUN_GOPHERD_DAEMON.COM -- $restart_server: $ set noon $ set nover $ set proc/priv=(noall, sysprv, tmpmbx, netmbx) $ if f$search("GOPHER_ROOT:[000000]_output70.*") - then purge/keep=3 GOPHER_ROOT:[000000]_output70.* $ if f$search("GOPHER_ROOT:[000000]_error70.*") - then purge/keep=3 GOPHER_ROOT:[000000]_error70.* $ set ver $ show time $ run gopher_exe:GopherD.exe $ sts = $status $ show time $ ctrstr = "Gopherd_Daemon exit /!AS/ !AS $ line = f$fao(ctrstr,f$trnlnm("GOPHER_RESTART_70"),f$message(sts)) $ request "''line'" $ mail NL: SYSTEM /noself /subj="''line'" $ if .not. sts $ then $ request "Restarting after abort..." $ goto restart_server $ endif $ restart := 'f$trnlnm("GOPHER_RESTART_70") $ show sym restart $ if restart .nes. "" $ then $ set proc/priv=(noall, sysprv) $ deassign/system GOPHER_RESTART_70 $ if restart .eqs. "RESTART" then request "Restarting..." $ if restart .eqs. "RESTART" then goto restart_server $ endif .