daemontools

最後更新: 2018-04-04

 

介紹

 

daemontools 一共有 5 個工具, 分別是

  • svc
  • svok
  • svscan
  • svscanboot
  • supervise

每個工具的關係:

                                            svc
                                              |
svscanboot -> svscan -> supervise -> process(./run)
                                              |
                                      svstat, svok

目錄


svstat

 

svstat - prints the status of services monitored by supervise

找出有什麼 Service

ls -1 /service

clamd
clear
qmail-pop3d
qmail-pop3ds
qmail-send
qmail-smtpd

e.g.

svstat qmail-smtpd

qmail-smtpd: up (pid 7237) 1427 seconds

 


svok

 

svok checks whether supervise is running (directory named service)

Usage: svok dir

i.e.

svok /service

echo $?

  • It silently exits 0 if supervise is successfully running.
  • It silently exits 100 if supervise is not successfully running.

 * 就算所有 Service 都正常, $? 都會是 100 的, 因為 "clear" 是 "normally down"

 


svc

 

svc - controls services monitored by supervise

Usage:

svc opts services

Opts

  • -u:  Up             # If the service is not running, start it.
  • -d:  Down         # If the service is running
  • -k:  Kill             # Send the service a KILL signal
  • -t:  Terminate    # Send the service a TERM signal.
  • -o:  Once.         # If the service is not running, start it. Do not restart it if it stops.
  • -x:  Exit.           # supervise will exit as soon as the service is down.

e.g.

svc -u clear                         # Up

svstat clear

clear: up (pid 12226) 0 seconds, normally down

svc -d clamd                       # Down

svstat clamd

clamd: up (pid 8924) 833 seconds

 


svscanboot

 

starts svscan in the /service directory

/etc/inittab

SV:2345:respawn:/command/svscanboot

 


svscan

 

starts one supervise process for each subdirectory of the current directory,

 * up to a limit of 1000 subdirectories
 * svscan skips subdirectory names starting with dots
 * Every five seconds, svscan checks for subdirectories again.
    (If it sees a new subdirectory, it starts a new supervise process.)
    (If it sees an old subdirectory where a supervise process has exited, it restarts the supervise process.)

 


supervise

 

supervise s

supervise switches to the directory named s and starts ./run

* If the file s/down exists, supervise does not start ./run immediately

supervise maintains status information in a binary format inside the directory s/supervise,

which must be writable to supervise.

The status information can be read by svstat.

 



相關

 

Creative Commons license icon Creative Commons license icon