upload http
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / server / mpm / monitoring-services.txt
1 From:    William A. Rowe, Jr. 
2 Date:    June 7th '00
3 Subject: service monitoring in Apache 1.3.13
4
5 The concept for a taskbar monitor has been thrown around
6 for a very long while.  1.3.13 introduced Win9x services,
7 and that added fuel to the mix.  Here are some sideband
8 observations I've made for other developers...
9
10 About Apache as a console, don't start Apache hidden without
11 any command line arguments if you want to launch it yourself
12 in a hidden window (it will do the classic test for 
13 AllocConsole/FreeConsole)... drop in some arguments such as
14 the -f or -r option and it will fly without thinking it is a 
15 service under 9x and NT.
16
17 Rule two, don't use --ntservice as an argument, ever.  Only
18 the Windows NT Service Control Manager is allowed to pass that
19 flag, and only that flag, when it runs Apache.exe.  Do use 
20 --ntservice as the sole argument to the executable name if 
21 you are installing an Apache NT service yourself.
22
23 Rule three, use -k start and -n name when maintaining the
24 HKLM/Software/Microsoft/Windows/CurrentVersion/RunServices
25 list, since there is no other way for Apache to know what 
26 the service is named :)  And look at any 9x installed service's 
27 RunServices entry in the registry for the start service semantic.
28
29 Rule four, use the WinNT Service Control Manager exclusively
30 for starting, stopping and restarting Apache as an NT service.
31 The restart signal is the value 128, as documented in service.h 
32 and service.c - this will continue to work in Apache 2.0.  If
33 it fails, you are handling an older version (pre 1.3.13) of
34 Apache, and need to stop and then start the service instead.
35
36 Rule five, use the legacy pid-named events to signal Win9x 
37 service Apache to restart and stop the service.  But don't
38 bother looking for httpd.pid files... you can get the pid
39 right from the hidden service control window.  Apache 1.3.13
40 and 2.x create a hidden window named for the name of the 
41 service (without the spaces), with a window class of
42 "ApacheWin95ServiceMonitor", so can use FindWindow to track 
43 down running Win9x services.  See the service.c code for how 
44 I accomplished this pretty simply in the -k stop/-k restart
45 handler.
46
47 Taskbar Monitor App
48 -------------------
49
50 Basic requirements: a C code application using strictly the
51 Win32 API, and not MFC or other Win32 frameworks.  Could use
52 the service.c module to share some basic functions.  That
53 module could be extended in Apache 2.0 to make this all easier.
54
55 I think we are looking for an external app that simply acts 
56 as a monitor or allows a stopped service to be started.  If 
57 the user logs off, we loose the monitor app, but installed as 
58 a shortcut in the Start group or in the registry key
59 HKLM/Software/Microsoft/Windows/CurrentVersion/Run
60 we will be just fine.  I'd like to see the monitor run only
61 one instance to monitor all running services, for memory
62 and resource conservation.
63
64 I was thinking that the hover/iconbar title would tell them 
65 "Test service is running", or "Test service is stopped".
66 If they left click, they could stop or restart, or simply
67 start if it is stopped.  There could be a preference that
68 each service doesn't get it's own individual task icon unless 
69 it is running, if it is a manual start service (or missing 
70 from the RunServices list, which is the equivilant under 9x).
71
72 If a specific service is set to Auto start or is in the 
73 RunServices Win9x registry key, we must show them the stopped 
74 icon, of course.  We might also keep the icon for any running
75 service that stops abruptly.  But there could be a 'single 
76 icon' option for the taskbar icon monitor that says show only
77 a single status icon, for simplicity if the administrator runs
78 many Apache services.
79
80 But I was hoping that any right click would provide a menu
81 of all Apache services with their status.  e.g.
82   Test service is stopped
83   Apache_2 service is running
84   MyWeb service is running
85 and each would do the logical submenu, same as if that
86 specific taskbar icon were left clicked, offering to start or
87 offering to stop or restart the server, as appropriate.
88
89 Finally, to identify all installed Apache services, just query 
90 the registry key HKLM\SYSTEM\CurrentControlSet\Services for any 
91 key that has the ImagePath value of "...\Apache.exe"... (quotes
92 are significant here, if the leading quote is ommitted the 
93 entire string ends with the text \Apache.exe - based on Apache's 
94 own service installer in every released version.)