diff options
author | Gerrit Pape <pape@smarden.org> | 2006-04-10 06:09:37 +0000 |
---|---|---|
committer | Gerrit Pape <pape@smarden.org> | 2006-04-10 06:09:37 +0000 |
commit | d8f520b5026bc2c5c67c95c46699b48daa5c77c1 (patch) | |
tree | ad1700ded6de901cc05e1852f76133ade0b52afd | |
parent | 59180db736d88ad8e02686b192f4f8c33e95783a (diff) | |
download | runit-d8f520b5026bc2c5c67c95c46699b48daa5c77c1.tar.gz runit-d8f520b5026bc2c5c67c95c46699b48daa5c77c1.tar.xz runit-d8f520b5026bc2c5c67c95c46699b48daa5c77c1.zip |
* man/runsvdir.8: document that the services directory is re-scanned if
the time of last modification, the inode, or the device has changed. * sv.c: don't report success on 'sv start' if the service is in state finish (thx Matthew R. Dempsky). * svlogd.c: new config line p: optionally prefix each line written to logs, stderr, or through udp; no longer skip empty lines (just containing '\n'), old behavior can be restored with '-' in config. * man/svlogd.8: document new p config line; adapt. 1.5.0.
-rw-r--r-- | man/runsvdir.8 | 23 | ||||
-rw-r--r-- | man/svlogd.8 | 10 | ||||
-rw-r--r-- | package/CHANGES | 11 | ||||
-rw-r--r-- | src/sv.c | 5 | ||||
-rw-r--r-- | src/svlogd.c | 45 |
5 files changed, 63 insertions, 31 deletions
diff --git a/man/runsvdir.8 b/man/runsvdir.8 index 7aa7249..adfa587 100644 --- a/man/runsvdir.8 +++ b/man/runsvdir.8 @@ -18,9 +18,13 @@ characters long or absent. .B runsvdir starts a .BR runsv (8) -process for each subdirectory in the services directory +process for each subdirectory, or symlink to a directory, in the services +directory .IR dir , -up to a limit of 1000 subdirectories. +up to a limit of 1000 subdirectories, +and restarts a +.BR runsv (8) +process if it terminates. .B runsvdir skips subdirectory names starting with dots. .BR runsv (8) @@ -30,20 +34,17 @@ PATH. .P At least every five seconds .B runsvdir -checks whether the services directory +checks whether the time of last modification, the inode, or the device, of +the services directory .I dir has changed. -If it sees a new subdirectory in +If so, it re-scans the service directory, and if it sees a new subdirectory, +or new symlink to a directory, in .IR dir , it starts a new .BR runsv (8) -process. -If it sees an old sudirectory where a -.BR runsv (8) -process has exited, it restarts the -.BR runsv (8) -process. -If +process; +if .B runsvdir sees a subdirectory being removed that was previously there, it sends the corresponding diff --git a/man/svlogd.8 b/man/svlogd.8 index 677ff8e..e8b03b7 100644 --- a/man/svlogd.8 +++ b/man/svlogd.8 @@ -158,8 +158,7 @@ exists, and if so, reads the file line by line and adjusts configuration for .I log as follows: .P -If the line is empty, less than two characters long, or starts with a ``#'', -it is ignored. +If the line is empty, or starts with a ``#'', it is ignored. A line of the form .TP .RI s size @@ -272,6 +271,13 @@ but transmitted through udp only. Error messages from .B svlogd concerning sending udp packages still go to the log directory. +.TP +.RI p prefix +tells +.B svlogd +to prefix each line to be written to the log directory, to standard error, +or through UDP, with +.IR prefix . .P If a line starts with a .IR \- , diff --git a/package/CHANGES b/package/CHANGES index cc2f507..492ccb7 100644 --- a/package/CHANGES +++ b/package/CHANGES @@ -1,3 +1,14 @@ +1.5.0 +Mon, 10 Apr 2006 06:09:08 +0000 + * man/runsvdir.8: document that the services directory is re-scanned if + the time of last modification, the inode, or the device has changed. + * sv.c: don't report success on 'sv start' if the service is in state + finish (thx Matthew R. Dempsky). + * svlogd.c: new config line p: optionally prefix each line written to + logs, stderr, or through udp; no longer skip empty lines (just + containing '\n'), old behavior can be restored with '-' in config. + * man/svlogd.8: document new p config line; adapt. + 1.4.1 Mon, 20 Mar 2006 18:54:41 +0000 * doc/faq.html: typos; add usercontrol, userservices; minor. diff --git a/src/sv.c b/src/sv.c index ce5bef5..a9592f4 100644 --- a/src/sv.c +++ b/src/sv.c @@ -215,7 +215,10 @@ int check(char *a) { pid <<=8; pid +=(unsigned char)svstatus[12]; switch (*a) { case 'x': return(0); - case 'u': if (!pid) return(0); if (!checkscript()) return(0); break; + case 'u': + if (!pid || svstatus[19] != 1) return(0); + if (!checkscript()) return(0); + break; case 'd': if (pid) return(0); break; case 'c': if (pid) if (!checkscript()) return(0); break; case 't': diff --git a/src/svlogd.c b/src/svlogd.c index 1ac6e72..6df4752 100644 --- a/src/svlogd.c +++ b/src/svlogd.c @@ -93,6 +93,7 @@ struct logdir { char matcherr; struct sockaddr_in udpaddr; unsigned int udponly; + stralloc prefix; } *dir; unsigned int dirn =0; @@ -419,6 +420,7 @@ unsigned int logdir_open(struct logdir *ld, const char *fn) { ld->match ='+'; ld->udpaddr.sin_port =0; ld->udponly =0; + while (! stralloc_copys(&ld->prefix, "")) pause_nomem(); while (! stralloc_copys(&ld->inst, "")) pause_nomem(); while (! stralloc_copys(&ld->processor, "")) pause_nomem(); @@ -431,9 +433,7 @@ unsigned int logdir_open(struct logdir *ld, const char *fn) { if (verbose) strerr_warn4(INFO, "read: ", ld->name, "/config", 0); for (i =0; i +1 < sa.len; ++i) { - if ((len =byte_chr(&sa.s[i], sa.len -i, '\n')) == 1) { - ++i; continue; - } + len =byte_chr(&sa.s[i], sa.len -i, '\n'); sa.s[len +i] =0; switch(sa.s[i]) { case '\n': @@ -473,8 +473,10 @@ unsigned int logdir_open(struct logdir *ld, const char *fn) { } break; case '!': - while (! stralloc_copys(&ld->processor, &sa.s[i +1])) pause_nomem(); - while (! stralloc_0(&ld->processor)) pause_nomem(); + if (len > 1) { + while (! stralloc_copys(&ld->processor, &sa.s[i +1])) pause_nomem(); + while (! stralloc_0(&ld->processor)) pause_nomem(); + } break; case 'U': ld->udponly =1; @@ -494,7 +496,7 @@ unsigned int logdir_open(struct logdir *ld, const char *fn) { port =514; ld->udpaddr.sin_port =htons(port); if (fdudp == -1) { - fdudp =socket(AF_INET, SOCK_DGRAM, 0); + fdudp =socket(AF_INET, SOCK_DGRAM, 0); if (fdudp) if (ndelay_on(fdudp) == -1) { close(fdudp); @@ -502,6 +504,12 @@ unsigned int logdir_open(struct logdir *ld, const char *fn) { } } break; + case 'p': + if (len > 1) { + while (! stralloc_copys(&ld->prefix, &sa.s[i +1])) pause_nomem(); + while (! stralloc_0(&ld->prefix)) pause_nomem(); + } + break; } i +=len; } @@ -723,7 +731,6 @@ int main(int argc, const char **argv) { char ch; linelen =0; - if (exitasap && ! data.p) break; /* data buffer is empty */ for (linelen =0; linelen < linemax; ++linelen) { if (buffer_GETC(&data, &ch) <= 0) { exitasap =1; @@ -755,12 +762,13 @@ int main(int argc, const char **argv) { } line[linelen] =ch; } - if (! linelen) continue; + if (exitasap && ! data.p) break; /* data buffer is empty */ for (i =0; i < dirn; ++i) if (dir[i].fddir != -1) { if (dir[i].inst.len) logmatch(&dir[i]); if (dir[i].matcherr == 'e') { if (timestamp) buffer_puts(buffer_2, stamp); + if (dir[i].prefix.len) buffer_puts(buffer_2, dir[i].prefix.s); buffer_put(buffer_2, line, linelen); if (linelen == linemax) buffer_puts(buffer_2, "..."); buffer_put(buffer_2, "\n", 1); buffer_flush(buffer_2); @@ -769,28 +777,31 @@ int main(int argc, const char **argv) { if (dir[i].udpaddr.sin_port != 0) { if (fdudp == -1) { buffer_puts(&dir[i].b, "warning: no udp socket available: "); + if (dir[i].prefix.len) buffer_puts(&dir[i].b, dir[i].prefix.s); buffer_put(&dir[i].b, line, linelen); buffer_put(&dir[i].b, "\n", 1); buffer_flush(&dir[i].b); } else { - if (linelen >= linemax -1) { - line[linemax -4] =line[linemax -3] =line[linemax -2] ='.'; - linelen =linemax -1; - } - if (line[linelen -1] != '\n') line[linelen++] ='\n'; - if (sendto(fdudp, line, linelen, 0, + while (! stralloc_copys(&sa, "")) pause_nomem(); + if (dir[i].prefix.len) + while (! stralloc_cats(&sa, dir[i].prefix.s)) pause_nomem(); + while (! stralloc_catb(&sa, line, linelen)) pause_nomem(); + if (linelen == linemax) + while (! stralloc_cats(&sa, "...")) pause_nomem(); + while (! stralloc_append(&sa, "\n")) pause_nomem(); + if (sendto(fdudp, sa.s, sa.len, 0, (struct sockaddr *)&dir[i].udpaddr, - sizeof(dir[i].udpaddr)) != linelen) { + sizeof(dir[i].udpaddr)) != sa.len) { buffer_puts(&dir[i].b, "warning: failure sending through udp: "); - buffer_put(&dir[i].b, line, linelen); + buffer_put(&dir[i].b, sa.s, sa.len); buffer_flush(&dir[i].b); } - if (line[linelen -1] == '\n') --linelen; } } if (! dir[i].udponly) { if (timestamp) buffer_puts(&dir[i].b, stamp); + if (dir[i].prefix.len) buffer_puts(&dir[i].b, dir[i].prefix.s); buffer_put(&dir[i].b, line, linelen); } } |