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