fiss-minit

A standalone service supervisor based on minit
Log | Files | Refs | README | LICENSE

commit 19b2ac16e6c4001e0779c06bca684cb63622d0e0
parent bbe9fad0afe47378da2a71904114040f47bc58fd
Author: sanjiyan <sanjiyan>
Date:   Tue, 22 Oct 2002 17:17:26 +0000

lines in depends can now be commented out with a #
add a method to clear dead services (mark as terminated)

Diffstat:
MCHANGES | 2++
Mminit.c | 12+++++++++++-
Mmsvc.c | 43+++++++++++++++++++++++++++++++------------
3 files changed, 44 insertions(+), 13 deletions(-)

diff --git a/CHANGES b/CHANGES @@ -5,6 +5,8 @@ explicit license statement and sent a patch to make debian packaging easier (deb files can't include FIFOs). Olaf: add write_proc. + Olaf: lines in depends can now be commented out with a # + Olaf: add a method to clear dead services (mark as terminated) 0.8: call waitpid repeatedly until it returns "no children". diff --git a/minit.c b/minit.c @@ -288,7 +288,9 @@ int startservice(int service,int pause) { int depc,i; deps=split(s,'\n',&depc,0,0); for (i=0; i<depc; i++) { - int service=loadservice(deps[i]); + int service; + if (deps[i][0]=='#') continue; + service=loadservice(deps[i]); if (service>=0 && root[service].pid!=1) startservice(service,0); } @@ -459,6 +461,13 @@ error: case 'R': root[idx].respawn=1; goto ok; + case 'C': + if (kill(root[idx].pid,0)) { /* check if still active */ + handlekilled(root[idx].pid); /* no!?! remove form active list */ + goto error; + } + goto ok; + break; case 'P': { unsigned char *x=buf+str_len(buf)+1; @@ -491,6 +500,7 @@ ok: } break; default: + break; } } } diff --git a/msvc.c b/msvc.c @@ -46,6 +46,16 @@ int setpid(char *service, pid_t pid) { } /* return nonzero if error */ +int check_remove(char *service) { + int len; + buf[0]='C'; + strncpy(buf+1,service,1400); + write(infd,buf,str_len(buf)); + len=read(outfd,buf,1500); + return (len!=1 || buf[0]=='0'); +} + +/* return nonzero if error */ int startservice(char *service) { int len; buf[0]='s'; @@ -71,18 +81,19 @@ main(int argc,char *argv[]) { int len; if (argc<2) { buffer_putsflush(buffer_1, - "usage: msvc -[uodpchaitko] service\n" - " msvc -Ppid service\n" - " -u up; start service with respawn\n" - " -o once; start service without respawn\n" - " -d down; disable respawn, stop service\n" - " -p pause; send SIGSTOP\n" - " -c continue; send SIGCONT\n" - " -h hangup; send SIGHUP\n" - " -a alarm; send SIGALRM\n" - " -i intr; send SIGINT\n" - " -t terminate; send SIGTERM\n" - " -k kill; send SIGKILL\n\n"); + "usage: msvc -[uodpchaitkoC] service\n" + " msvc -Ppid service\n" + " -u\tup; start service with respawn\n" + " -o\tonce; start service without respawn\n" + " -d\tdown; disable respawn, stop service\n" + " -p\tpause; send SIGSTOP\n" + " -c\tcontinue; send SIGCONT\n" + " -h\thangup; send SIGHUP\n" + " -a\talarm; send SIGALRM\n" + " -i\tintr; send SIGINT\n" + " -t\tterminate; send SIGTERM\n" + " -k\tkill; send SIGKILL\n" + " -C\tClear; remove service form active list\n\n"); return 0; } infd=open("/etc/minit/in",O_WRONLY); @@ -149,6 +160,14 @@ main(int argc,char *argv[]) { goto error; } break; + case 'C': + if (check_remove(argv[2])) { + buffer_puts(buffer_2,"Service "); + buffer_puts(buffer_2,argv[2]); + buffer_putsflush(buffer_2," had terminated or was killed\n"); + goto error; + } + break; case 'P': pid=atoi(argv[1]+2); if (pid>1)