aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-02-25 13:29:01 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-02-25 13:29:01 +0000
commit9305084973d7e7fa1ca33cade45ee6f9732055b7 (patch)
treedc735d221e5e5039a415db73c753ed7de755acc7 /src
parent58ed3fae4fe7c3c972e801698a0e8f1c615213ce (diff)
downloadrspamd-9305084973d7e7fa1ca33cade45ee6f9732055b7.tar.gz
rspamd-9305084973d7e7fa1ca33cade45ee6f9732055b7.zip
[Minor] Allow to set process title for lua processes
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_worker.c14
-rw-r--r--src/plugins/lua/neural.lua3
2 files changed, 13 insertions, 4 deletions
diff --git a/src/lua/lua_worker.c b/src/lua/lua_worker.c
index 4364a1b86..f7f4b3c68 100644
--- a/src/lua/lua_worker.c
+++ b/src/lua/lua_worker.c
@@ -757,7 +757,7 @@ lua_worker_spawn_process (lua_State *L)
struct rspamd_lua_process_cbdata *cbdata;
struct rspamd_abstract_worker_ctx *actx;
struct rspamd_srv_command srv_cmd;
- const gchar *cmdline = NULL, *input = NULL;
+ const gchar *cmdline = NULL, *input = NULL, *proctitle = NULL;
gsize inputlen = 0;
pid_t pid;
GError *err = NULL;
@@ -765,8 +765,8 @@ lua_worker_spawn_process (lua_State *L)
if (!rspamd_lua_parse_table_arguments (L, 2, &err,
RSPAMD_LUA_PARSE_ARGUMENTS_DEFAULT,
- "func=F;exec=S;stdin=V;*on_complete=F", &func_cbref,
- &cmdline, &inputlen, &input, &cb_cbref)) {
+ "func=F;exec=S;stdin=V;*on_complete=F;proctitle=S", &func_cbref,
+ &cmdline, &inputlen, &input, &cb_cbref, &proctitle)) {
msg_err ("cannot get parameters list: %e", err);
if (err) {
@@ -834,6 +834,14 @@ lua_worker_spawn_process (lua_State *L)
rspamd_socket_blocking (cbdata->sp[1]);
g_hash_table_remove_all (w->signal_events);
ev_loop_destroy (cbdata->event_loop);
+
+ if (proctitle) {
+ setproctitle ("lua process: %s", proctitle);
+ }
+ else {
+ setproctitle ("lua process: unnamed");
+ }
+
cbdata->event_loop = ev_loop_new (EVFLAG_SIGNALFD);
rspamd_worker_unblock_signals ();
rspamd_lua_execute_lua_subprocess (L, cbdata);
diff --git a/src/plugins/lua/neural.lua b/src/plugins/lua/neural.lua
index da569e698..cd870534f 100644
--- a/src/plugins/lua/neural.lua
+++ b/src/plugins/lua/neural.lua
@@ -103,7 +103,7 @@ end
local redis_lua_script_can_store_train_vec = [[
local prefix = KEYS[1]
local locked = redis.call('HGET', prefix, 'lock')
- if locked then return {tostring(-1),'locked by another process: ' .. locked} end
+ if locked then return {tostring(-1),'locked by another process till: ' .. locked} end
local nspam = 0
local nham = 0
local lim = tonumber(KEYS[3])
@@ -726,6 +726,7 @@ local function spawn_train(worker, ev_base, rule, set, ann_key, ham_vec, spam_ve
worker:spawn_process{
func = train,
on_complete = ann_trained,
+ proctitle = string.format("ANN train for %s/%s", rule.prefix, set.name),
}
end
-- Spawn learn and register lock extension