meetbill / supervise Goto Github PK
View Code? Open in Web Editor NEW基于 D. J. Bernstein's daemontools https://cr.yp.to/daemontools.html
基于 D. J. Bernstein's daemontools https://cr.yp.to/daemontools.html
执行文件会输出信息到 stdout & stderr,如
test.sh
while :
do
date
sleep 1
done
直接执行如下命令
./supervise -p "status/test" -f "./test.sh 1>>__stdout 2>&1"
发现并没有产生 __stdout 文件
执行 lsof -p ${pid}
输出如下
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
...
test.sh 22878 work 0u CHR 1,3 0t0 1028 /dev/null
test.sh 22878 work 1u CHR 1,3 0t0 1028 /dev/null
test.sh 22878 work 2u CHR 1,3 0t0 1028 /dev/null
如果不想改动原进程,可以在 supervise 上进行改动
diff --git a/supervise/supervise.c b/supervise/supervise.c
--- a/supervise/supervise.c
+++ b/supervise/supervise.c
@@ -463,6 +463,8 @@ static void trystart()
case 0:
sig_uncatch(sig_child);
sig_unblock(sig_child);
+ freopen("_stdout.log", "a+", stdout);
+ freopen("_stderr.log", "a+", stderr);
execvp(cmd[0], cmdp);
write_log(fdlogwf, FATAL, "unable to start ", cmd[0], "\n");
_exit(1);
如果想可配置,可以将配置项配置到 supervise.conf 中
如果用 od -d status 或 od -t u2 status 读取 2 字节,无符号短整型,最大值是 65535。
-d 此参数的效果和同时指定"-tu2"参数相同
如果 cat /proc/sys/kernel/pid_max 大于这个数。od -d status
读出来的 pid 就有可能是错的。
static void pidchange()
{
struct taia now;
unsigned long u;
taia_now(&now);
taia_pack(status, &now);
u = (unsigned long) pid;
status[16] = u; u >>= 8;
status[17] = u; u >>= 8;
status[18] = u; u >>= 8;
status[19] = u;
}
需要修改为
旧:
pid=$(od -d status | head -n 2 | tail -n 1 | awk '{print $2}')
需要改为:
od -An -j16 -N4 -tu4 status
make
make --directory=supervise
make[1]: Entering directory '/home/meetbill/supervise/supervise'
sh find-systype.sh > systype
rm -f compile
sh print-cc.sh > compile
chmod 555 compile
./compile byte_chr.c
./compile byte_copy.c
./compile byte_cr.c
./compile byte_diff.c
./compile byte_rchr.c
./compile fmt_uint.c
./compile fmt_uint0.c
./compile fmt_ulong.c
rm -f makelib
sh print-ar.sh > makelib
chmod 555 makelib
./compile scan_ulong.c
./compile str_chr.c
./compile str_diff.c
./compile str_len.c
./compile str_start.c
./makelib byte.a byte_chr.o byte_copy.o byte_cr.o byte_diff.o \
byte_rchr.o fmt_uint.o fmt_uint0.o fmt_ulong.o scan_ulong.o str_chr.o \
str_diff.o str_len.o str_start.o
make[1]: *** No rule to make target 'home', needed by 'choose'. Stop.
make[1]: Leaving directory '/home/meetbill/supervise/supervise'
make: *** [Makefile:6: supervise] Error 2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.