In preparation for 2.0
[freeradius.git] / doc / supervise-radiusd.txt
1
2 Supervising the Radiusd Daemon
3
4 0.  INTRODUCTION
5
6     We all hope that our radius daemons won't die in the middle of the
7     nite stranding customer and beeping beepers.  But, alas, it's going
8     to happen, and when you least expect it.  That's why you want a 
9     another process watching your radius daemon, restarting it if and
10     when it dies.
11
12     This text describes how to setup both the free radius daemon so that
13     it is automatically restarted upon death.  To do this, we'll use
14     either Dan Bernstein's 'daemontools' package or the inittab file.
15
16     Note: The radwatch script that used to be part of this distribution,
17     is depreciated and SHOULD NOT BE USED.
18
19 1.  SETTING UP DAEMONTOOLS
20
21     First, download (and install) daemontools from:
22
23     http://cr.yp.to/daemontools.html
24
25     The latest version as of this writing is 0.70.  It would be well
26     worth your while to read all the documentation at that site too,
27     as you can do much more with daemontools than I describe here.
28
29     Next, we'll need a directory for the radius 'service' to use with 
30     daemontools.  I usually create a dir '/var/svc' to hold all my
31     daemontool supervised services.  Ie:
32
33     # mkdir /var/svc
34     # mkdir /var/svc/radiusd
35
36     Now we just need a short shell script called 'run' in our new
37     service directory that will start our daemon.  The following should
38     get you started:
39
40     /var/svc/radiusd/run:
41     ---------------------
42     #!/bin/sh
43     exec /usr/local/sbin/radiusd -s -f 
44
45     Of course you'll want to make that 'run' file executable:
46
47     # chmod +x /var/svc/radiusd/run
48
49     Note, you *MUST* use the '-f' option when supervising.  That option
50     tells radiusd not to detach from the tty when starting.  If you don't
51     use that option, the daemontools will always think that radiusd has
52     just died and will (try to) restart it.  Not good.
53
54     Now the only left to do is to start the 'supervise' command that
55     came with daemontools.  Do that like so:
56
57     # supervise /var/svc/radiusd
58
59 2.  MAINTENANCE WITH DAEMONTOOLS
60
61     Any maintenance you need to do with almost certainly be done with the
62     'svc' program in the deamontools package.  Ie:
63
64     Shutdown radiusd:
65     # svc -d /var/svc/radiusd
66
67     Start it back up:
68     # svc -u /var/svc/radiusd
69
70     Send HUP to radiusd:
71     # svc -h /var/svc/radiusd 
72
73     Shutdown and stop supervising radiusd:
74     # svc -dx /var/svc/radiusd
75
76 3.  SUPERVISING WITH INITTAB
77
78     This is really pretty easy, but it is system dependent.  I strongly
79     suggest you read the man pages for your 'init' before playing with 
80     this.  You can seriously hose your system if you screw up your
81     inittab.
82     
83     Add this line (or something similar to it) to your inittab:
84
85     fr:23:respawn:/usr/local/sbin/radiusd -f -s &> /dev/null
86
87     Now all that's left is to have the system reread the inittab.  Usually
88     that's done with one of the following:
89
90     # telinit Q
91      <or>
92     # init q
93
94     Now you should see a 'radiusd' process when you issue a 'ps'.  If you
95     don't, try to run the radiusd command you put in inittab manually.
96     If it works, that means you didn't tell the system to reread inittab
97     properly.  If it doesn't work, that means your radius start command
98     is bad and you need to fix it.
99
100 4.  ACKNOWLEDGEMENTS
101  
102     Document author:  Jeff Carneal
103     daemontools auther:  Dan Bernstein
104     Further daemontool notes (below):  Antonio Dias
105     Radwatch note: Andrey Melnikov
106
107 5.  FURTHER DAEMONTOOLS NOTES
108
109     Here are some notes by Antonia Dias sent to the free radius mailing list.
110     Some of you may find this useful after reading the above and the docs for
111     daemontools.
112  
113     -------------------------------------------------------------------------
114
115     daemontools instructions
116     
117     I am running radiusd under supervise from daemontools without problems.
118     The only thing I am missing right now is an option to force radiusd to
119     send log to stderr so I can manage logs better with multilog (also
120     included in daemontools package). Here is the procedure I've been
121     following (for Cistron RADIUS):
122     
123         root@storm:~> groupadd log
124         root@storm:~> useradd -g log log
125         root@storm:~> mkdir /etc/radiusd
126         root@storm:~> mkdir /etc/radiusd/log
127         root@storm:~> mkdir /etc/radiusd/log/main
128         root@storm:~> chmod +t+s /etc/radiusd /etc/radiusd/log
129         root@storm:~> chown log.log /etc/radiusd/log/main
130     
131     Here are the contents of run files from /etc/radiusd and /etc/radiusd/log
132     
133         root@storm:~> cd /etc/radiusd
134         root@storm:/etc/radiusd> cat run
135         #!/bin/sh
136         exec 2>&1
137         exec /usr/sbin/radiusd -fyzx
138         root@storm:/etc/radiusd> cd /etc/radiusd/log
139         root@storm:/etc/radiusd/log> cat run
140         #!/bin/sh
141         exec setuidgid log multilog t ./main
142     
143     To make service wake-up do:
144         root@storm:~> ln -sf /etc/radiusd /service
145     
146     Hang-up (to reload config) it using:
147         root@storm:~> svc -h /service/radiusd
148     
149     Disable (down) it using:
150         root@storm:~> svc -d /service/radiusd
151     
152     Reenable (up) it using:
153         root@storm:~> svc -u /service/radiusd
154     
155     -- 
156     Antonio Dias
157