diff --git a/README.md b/README.md index f205371..6e51b45 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,7 @@ Conf = [ 'ip': '127.0.0.1', 'port': '8606', ], + 'bootstrap_cmd': '', ]; ``` diff --git a/bootstrap.m b/bootstrap.m new file mode 100644 index 0000000..5a65ef1 --- /dev/null +++ b/bootstrap.m @@ -0,0 +1,9 @@ +#include "@/log.m" + +sys = Import('sys'); + +if (Conf['bootstrap_cmd']) { + Log('info', 'running command [' + Conf['bootstrap_cmd'] + '] ...'); + sys.msleep(1000); + sys.exec(Conf['bootstrap_cmd'], -1, pid, nil, nil, 'bootstrap'); +} fi diff --git a/conf/conf.m b/conf/conf.m index 4843eb7..b3429c5 100644 --- a/conf/conf.m +++ b/conf/conf.m @@ -10,6 +10,7 @@ 'ip': '127.0.0.1', 'port': '8606', ], + 'bootstrap_cmd': '', ]; /* diff --git a/meproc.m b/meproc.m index 9cd1a08..8acb916 100644 --- a/meproc.m +++ b/meproc.m @@ -10,9 +10,10 @@ return; } fi -Log('info', "Meproc v1.0.0. Listen on: " + Conf['ip'] + ':' + Conf['port']); +Log('info', "Meproc v1.0.1. Listen on: " + Conf['ip'] + ':' + Conf['port']); Eval('@/http.m'); +Eval('@/bootstrap.m', nil, false, 'bootstrap'); while (1) { fd = net.tcp_accept(listenfd); diff --git a/proc.m b/proc.m index 4240201..09e4821 100644 --- a/proc.m +++ b/proc.m @@ -275,6 +275,9 @@ n = S.size(list); for (i = 0; i < n; ++i) { name = Str.slice(list[i]['alias'], ':')[0]; + if (name == 'bootstrap') + continue; + fi if (!S.has(Tasks, name) || !Tasks[name]) { Log('error', "Task [" + name + "] is running but not in Tasks"); continue; @@ -358,5 +361,9 @@ } fi } } + data = Mq.recv('bootstrap', 1); + if (data) { + TaskLog('bootstrap', data); + } fi }