comparison util/startup.lua @ 13639:94f77a1994dc

util.startup: Drop mention of systemd from notification socket handling This does not have to be specific to systemd
author Kim Alvefur <zash@zash.se>
date Sat, 01 Feb 2025 20:42:59 +0100
parents 8228f5094f7a
children 5abdcad8c2e0
comparison
equal deleted inserted replaced
13638:94462d8f2fa9 13639:94f77a1994dc
812 log("info", "Received SIGUSR2"); 812 log("info", "Received SIGUSR2");
813 prosody.events.fire_event("signal/SIGUSR2"); 813 prosody.events.fire_event("signal/SIGUSR2");
814 end); 814 end);
815 end 815 end
816 816
817 function startup.systemd_notify() 817 function startup.notification_socket()
818 local notify_socket_name = os.getenv("NOTIFY_SOCKET"); 818 local notify_socket_name = os.getenv("NOTIFY_SOCKET");
819 if not notify_socket_name then return end 819 if not notify_socket_name then return end
820 local have_unix, unix = pcall(require, "socket.unix"); 820 local have_unix, unix = pcall(require, "socket.unix");
821 if not have_unix or type(unix) ~= "table" then 821 if not have_unix or type(unix) ~= "table" then
822 log("error", "LuaSocket without UNIX socket support, can't notify systemd.") 822 log("error", "LuaSocket without UNIX socket support, can't notify process manager.")
823 return os.exit(1); 823 return os.exit(1);
824 end 824 end
825 log("debug", "Will notify on socket %q", notify_socket_name); 825 log("debug", "Will notify on socket %q", notify_socket_name);
826 notify_socket_name = notify_socket_name:gsub("^@", "\0"); 826 notify_socket_name = notify_socket_name:gsub("^@", "\0");
827 local notify_socket = unix.dgram(); 827 local notify_socket = unix.dgram();
828 local ok, err = notify_socket:setpeername(notify_socket_name); 828 local ok, err = notify_socket:setpeername(notify_socket_name);
829 if not ok then 829 if not ok then
830 log("error", "Could not connect to systemd notification socket %q: %q", notify_socket_name, err); 830 log("error", "Could not connect to notification socket %q: %q", notify_socket_name, err);
831 return os.exit(1); 831 return os.exit(1);
832 end 832 end
833 local time = require "prosody.util.time"; 833 local time = require "prosody.util.time";
834 834
835 prosody.notify_socket = notify_socket; 835 prosody.notify_socket = notify_socket;
926 startup.init_data_store(); 926 startup.init_data_store();
927 startup.init_global_protection(); 927 startup.init_global_protection();
928 startup.posix_daemonize(); 928 startup.posix_daemonize();
929 startup.write_pidfile(); 929 startup.write_pidfile();
930 startup.hook_posix_signals(); 930 startup.hook_posix_signals();
931 startup.systemd_notify(); 931 startup.notification_socket();
932 startup.prepare_to_start(); 932 startup.prepare_to_start();
933 startup.notify_started(); 933 startup.notify_started();
934 end 934 end
935 935
936 return startup; 936 return startup;