]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow to set process title for lua processes
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 25 Feb 2020 13:29:01 +0000 (13:29 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 25 Feb 2020 13:29:01 +0000 (13:29 +0000)
src/lua/lua_worker.c
src/plugins/lua/neural.lua

index 4364a1b869392965247cebe16c3001a49fa657bb..f7f4b3c68450dbf9a564975a565fd3adc73457f5 100644 (file)
@@ -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);
index da569e69853f7154e4d19bab1a253bd0d983fd9f..cd870534fd0ac45f7fed94673d353e8c88826b37 100644 (file)
@@ -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