annotate plugins/mod_posix.lua @ 13452:69faf3552d52

mod_posix: Move POSIX signal handling into util.startup to avoid race When libunbound is initialized, it spawns a thread to work in. In case a module initializes libunbound, e.g. by triggering a s2s connection, Prosody would not handle signals, instead immediately quit on e.g. the reload (SIGHUP) signal. Likely because the libunbound thread would not have inherited the signal mask from the main Prosody thread. Thanks Menel, riau and franck-x for reporting and help narrowing down
author Kim Alvefur <zash@zash.se>
date Sat, 02 Mar 2024 13:23:24 +0100
parents 74b9e05af71e
children c673ff1075bd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1522
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1238
diff changeset
1 -- Prosody IM
2923
b7049746bd29 Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents: 2795
diff changeset
2 -- Copyright (C) 2008-2010 Matthew Wild
b7049746bd29 Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents: 2795
diff changeset
3 -- Copyright (C) 2008-2010 Waqas Hussain
5776
bd0ff8ae98a8 Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 5452
diff changeset
4 --
1522
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1238
diff changeset
5 -- This project is MIT/X11 licensed. Please see the
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1238
diff changeset
6 -- COPYING file in the source package for more information.
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1238
diff changeset
7 --
569d58d21612 Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents: 1238
diff changeset
8
728
fa45dfb27ee5 mod_posix: Check version of pposix
Matthew Wild <mwild1@gmail.com>
parents: 723
diff changeset
9
8012
e898c8fda986 util.pposix: Remove fallocate
Kim Alvefur <zash@zash.se>
parents: 8010
diff changeset
10 local want_pposix_version = "0.4.0";
587
43f509a1519a Add mod_posix, fixes #5
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11
12977
74b9e05af71e plugins: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents: 12297
diff changeset
12 local pposix = assert(require "prosody.util.pposix");
5452
edf3db386a19 mod_posix: Improve error message for a pposix version mismatch
Matthew Wild <mwild1@gmail.com>
parents: 5451
diff changeset
13 if pposix._VERSION ~= want_pposix_version then
8166
bbedf564b9f9 mod_posix: Split long line [luacheck]
Kim Alvefur <zash@zash.se>
parents: 8116
diff changeset
14 module:log("warn", "Unknown version (%s) of binary pposix module, expected %s."
bbedf564b9f9 mod_posix: Split long line [luacheck]
Kim Alvefur <zash@zash.se>
parents: 8116
diff changeset
15 .. "Perhaps you need to recompile?", tostring(pposix._VERSION), want_pposix_version);
5452
edf3db386a19 mod_posix: Improve error message for a pposix version mismatch
Matthew Wild <mwild1@gmail.com>
parents: 5451
diff changeset
16 end
587
43f509a1519a Add mod_posix, fixes #5
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17
991
cd0d75de8345 mod_posix: Allow logging and pidfile options to take effect without needing to daemonize. Add the ability to catch SIGTERM.
Matthew Wild <mwild1@gmail.com>
parents: 735
diff changeset
18
2793
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
19 local lfs = require "lfs";
2795
d6fcd13c07e7 mod_posix: Adjust file open mode depending on whether file exists (take that fopen designers!!!)
Matthew Wild <mwild1@gmail.com>
parents: 2793
diff changeset
20 local stat = lfs.attributes;
2793
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
21
1238
f4c08caca3e7 mod_posix: Use global prosody object
Matthew Wild <mwild1@gmail.com>
parents: 1119
diff changeset
22 local prosody = _G.prosody;
f4c08caca3e7 mod_posix: Use global prosody object
Matthew Wild <mwild1@gmail.com>
parents: 1119
diff changeset
23
4623
403b56b78018 mod_posix, mod_bosh, mod_admin_telnet: Use module:set_global()
Kim Alvefur <zash@zash.se>
parents: 3555
diff changeset
24 module:set_global(); -- we're a global module
587
43f509a1519a Add mod_posix, fixes #5
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25
7731
a0ee83c4a82c mod_posix: Use type-specific config API
Kim Alvefur <zash@zash.se>
parents: 6875
diff changeset
26 local umask = module:get_option_string("umask", "027");
2440
11e3d16a128f mod_posix: Set umask to 'umask' from the config, or 027
Matthew Wild <mwild1@gmail.com>
parents: 2438
diff changeset
27 pposix.umask(umask);
11e3d16a128f mod_posix: Set umask to 'umask' from the config, or 027
Matthew Wild <mwild1@gmail.com>
parents: 2438
diff changeset
28
1092
b547967d87fc mod_posix: Don't let the server run as root without the magic run_as_root in config
Matthew Wild <mwild1@gmail.com>
parents: 1062
diff changeset
29 -- Don't even think about it!
3022
948d511f479c mod_posix: Don't add a server-starting event handler while the server-starting event is being fired.
Waqas Hussain <waqas20@gmail.com>
parents: 2925
diff changeset
30 if not prosody.start_time then -- server-starting
11047
93cdd1ece689 mod_posix: Remove ancient undocumented user switching
Kim Alvefur <zash@zash.se>
parents: 10628
diff changeset
31 if pposix.getuid() == 0 and not module:get_option_boolean("run_as_root") then
93cdd1ece689 mod_posix: Remove ancient undocumented user switching
Kim Alvefur <zash@zash.se>
parents: 10628
diff changeset
32 module:log("error", "Danger, Will Robinson! Prosody doesn't need to be run as root, so don't do it!");
93cdd1ece689 mod_posix: Remove ancient undocumented user switching
Kim Alvefur <zash@zash.se>
parents: 10628
diff changeset
33 module:log("error", "For more information on running Prosody as root, see https://prosody.im/doc/root");
11830
7fe2fbfbdb1c mod_posix: Exit with non-zero status code on problems
Kim Alvefur <zash@zash.se>
parents: 11179
diff changeset
34 prosody.shutdown("Refusing to run as root", 1);
3022
948d511f479c mod_posix: Don't add a server-starting event handler while the server-starting event is being fired.
Waqas Hussain <waqas20@gmail.com>
parents: 2925
diff changeset
35 end
948d511f479c mod_posix: Don't add a server-starting event handler while the server-starting event is being fired.
Waqas Hussain <waqas20@gmail.com>
parents: 2925
diff changeset
36 end
1092
b547967d87fc mod_posix: Don't let the server run as root without the magic run_as_root in config
Matthew Wild <mwild1@gmail.com>
parents: 1062
diff changeset
37
2793
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
38 local pidfile;
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
39 local pidfile_handle;
1032
409f22d0430f mod_posix: Remove pidfile on exit
Matthew Wild <mwild1@gmail.com>
parents: 991
diff changeset
40
409f22d0430f mod_posix: Remove pidfile on exit
Matthew Wild <mwild1@gmail.com>
parents: 991
diff changeset
41 local function remove_pidfile()
2793
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
42 if pidfile_handle then
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
43 pidfile_handle:close();
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
44 os.remove(pidfile);
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
45 pidfile, pidfile_handle = nil, nil;
1032
409f22d0430f mod_posix: Remove pidfile on exit
Matthew Wild <mwild1@gmail.com>
parents: 991
diff changeset
46 end
409f22d0430f mod_posix: Remove pidfile on exit
Matthew Wild <mwild1@gmail.com>
parents: 991
diff changeset
47 end
409f22d0430f mod_posix: Remove pidfile on exit
Matthew Wild <mwild1@gmail.com>
parents: 991
diff changeset
48
991
cd0d75de8345 mod_posix: Allow logging and pidfile options to take effect without needing to daemonize. Add the ability to catch SIGTERM.
Matthew Wild <mwild1@gmail.com>
parents: 735
diff changeset
49 local function write_pidfile()
2793
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
50 if pidfile_handle then
1032
409f22d0430f mod_posix: Remove pidfile on exit
Matthew Wild <mwild1@gmail.com>
parents: 991
diff changeset
51 remove_pidfile();
409f22d0430f mod_posix: Remove pidfile on exit
Matthew Wild <mwild1@gmail.com>
parents: 991
diff changeset
52 end
7992
51396e0836cf mod_posix: Use path variant of config API for pidfile option
Kim Alvefur <zash@zash.se>
parents: 7731
diff changeset
53 pidfile = module:get_option_path("pidfile", nil, "data");
991
cd0d75de8345 mod_posix: Allow logging and pidfile options to take effect without needing to daemonize. Add the ability to catch SIGTERM.
Matthew Wild <mwild1@gmail.com>
parents: 735
diff changeset
54 if pidfile then
3026
dec4527a7499 mod_posix: Fixed a global access.
Waqas Hussain <waqas20@gmail.com>
parents: 2923
diff changeset
55 local err;
2795
d6fcd13c07e7 mod_posix: Adjust file open mode depending on whether file exists (take that fopen designers!!!)
Matthew Wild <mwild1@gmail.com>
parents: 2793
diff changeset
56 local mode = stat(pidfile) and "r+" or "w+";
d6fcd13c07e7 mod_posix: Adjust file open mode depending on whether file exists (take that fopen designers!!!)
Matthew Wild <mwild1@gmail.com>
parents: 2793
diff changeset
57 pidfile_handle, err = io.open(pidfile, mode);
2793
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
58 if not pidfile_handle then
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
59 module:log("error", "Couldn't write pidfile at %s; %s", pidfile, err);
11830
7fe2fbfbdb1c mod_posix: Exit with non-zero status code on problems
Kim Alvefur <zash@zash.se>
parents: 11179
diff changeset
60 prosody.shutdown("Couldn't write pidfile", 1);
991
cd0d75de8345 mod_posix: Allow logging and pidfile options to take effect without needing to daemonize. Add the ability to catch SIGTERM.
Matthew Wild <mwild1@gmail.com>
parents: 735
diff changeset
61 else
2793
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
62 if not lfs.lock(pidfile_handle, "w") then -- Exclusive lock
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
63 local other_pid = pidfile_handle:read("*a");
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
64 module:log("error", "Another Prosody instance seems to be running with PID %s, quitting", other_pid);
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
65 pidfile_handle = nil;
11830
7fe2fbfbdb1c mod_posix: Exit with non-zero status code on problems
Kim Alvefur <zash@zash.se>
parents: 11179
diff changeset
66 prosody.shutdown("Prosody already running", 1);
2793
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
67 else
3341
a8a3e662fea7 mod_posix: Some (perhaps temporary) changes to re-lock the pidfile after truncating, to avoid breaking prosodyctl
Matthew Wild <mwild1@gmail.com>
parents: 3340
diff changeset
68 pidfile_handle:close();
3340
0769cc5f34b6 mod_posix: Truncate the pidfile before writing to ensure that we never overwrite with a PID shorter than the previous, and end with an invalid PID in the file.
Brian Cully <bjc@junctionnetworks.com>
parents: 3029
diff changeset
69 pidfile_handle, err = io.open(pidfile, "w+");
0769cc5f34b6 mod_posix: Truncate the pidfile before writing to ensure that we never overwrite with a PID shorter than the previous, and end with an invalid PID in the file.
Brian Cully <bjc@junctionnetworks.com>
parents: 3029
diff changeset
70 if not pidfile_handle then
0769cc5f34b6 mod_posix: Truncate the pidfile before writing to ensure that we never overwrite with a PID shorter than the previous, and end with an invalid PID in the file.
Brian Cully <bjc@junctionnetworks.com>
parents: 3029
diff changeset
71 module:log("error", "Couldn't write pidfile at %s; %s", pidfile, err);
11830
7fe2fbfbdb1c mod_posix: Exit with non-zero status code on problems
Kim Alvefur <zash@zash.se>
parents: 11179
diff changeset
72 prosody.shutdown("Couldn't write pidfile", 1);
3341
a8a3e662fea7 mod_posix: Some (perhaps temporary) changes to re-lock the pidfile after truncating, to avoid breaking prosodyctl
Matthew Wild <mwild1@gmail.com>
parents: 3340
diff changeset
73 else
a8a3e662fea7 mod_posix: Some (perhaps temporary) changes to re-lock the pidfile after truncating, to avoid breaking prosodyctl
Matthew Wild <mwild1@gmail.com>
parents: 3340
diff changeset
74 if lfs.lock(pidfile_handle, "w") then
a8a3e662fea7 mod_posix: Some (perhaps temporary) changes to re-lock the pidfile after truncating, to avoid breaking prosodyctl
Matthew Wild <mwild1@gmail.com>
parents: 3340
diff changeset
75 pidfile_handle:write(tostring(pposix.getpid()));
a8a3e662fea7 mod_posix: Some (perhaps temporary) changes to re-lock the pidfile after truncating, to avoid breaking prosodyctl
Matthew Wild <mwild1@gmail.com>
parents: 3340
diff changeset
76 pidfile_handle:flush();
a8a3e662fea7 mod_posix: Some (perhaps temporary) changes to re-lock the pidfile after truncating, to avoid breaking prosodyctl
Matthew Wild <mwild1@gmail.com>
parents: 3340
diff changeset
77 end
3340
0769cc5f34b6 mod_posix: Truncate the pidfile before writing to ensure that we never overwrite with a PID shorter than the previous, and end with an invalid PID in the file.
Brian Cully <bjc@junctionnetworks.com>
parents: 3029
diff changeset
78 end
2793
08892e3f24bd mod_posix: Lock pidfile when in use, shut down if we can't write or lock the pidfile
Matthew Wild <mwild1@gmail.com>
parents: 2074
diff changeset
79 end
991
cd0d75de8345 mod_posix: Allow logging and pidfile options to take effect without needing to daemonize. Add the ability to catch SIGTERM.
Matthew Wild <mwild1@gmail.com>
parents: 735
diff changeset
80 end
cd0d75de8345 mod_posix: Allow logging and pidfile options to take effect without needing to daemonize. Add the ability to catch SIGTERM.
Matthew Wild <mwild1@gmail.com>
parents: 735
diff changeset
81 end
cd0d75de8345 mod_posix: Allow logging and pidfile options to take effect without needing to daemonize. Add the ability to catch SIGTERM.
Matthew Wild <mwild1@gmail.com>
parents: 735
diff changeset
82 end
cd0d75de8345 mod_posix: Allow logging and pidfile options to take effect without needing to daemonize. Add the ability to catch SIGTERM.
Matthew Wild <mwild1@gmail.com>
parents: 735
diff changeset
83
10598
5cf481bee678 mod_posix: Support for command-line flags to override 'daemonize' config option
Matthew Wild <mwild1@gmail.com>
parents: 9763
diff changeset
84 local daemonize = prosody.opts.daemonize;
5cf481bee678 mod_posix: Support for command-line flags to override 'daemonize' config option
Matthew Wild <mwild1@gmail.com>
parents: 9763
diff changeset
85
5cf481bee678 mod_posix: Support for command-line flags to override 'daemonize' config option
Matthew Wild <mwild1@gmail.com>
parents: 9763
diff changeset
86 if daemonize == nil then
5cf481bee678 mod_posix: Support for command-line flags to override 'daemonize' config option
Matthew Wild <mwild1@gmail.com>
parents: 9763
diff changeset
87 -- Fall back to config file if not specified on command-line
10628
25e178edbc2c mod_posix: Add deprecation warning for the 'daemonize' option
Kim Alvefur <zash@zash.se>
parents: 10599
diff changeset
88 daemonize = module:get_option_boolean("daemonize", nil);
25e178edbc2c mod_posix: Add deprecation warning for the 'daemonize' option
Kim Alvefur <zash@zash.se>
parents: 10599
diff changeset
89 if daemonize ~= nil then
25e178edbc2c mod_posix: Add deprecation warning for the 'daemonize' option
Kim Alvefur <zash@zash.se>
parents: 10599
diff changeset
90 module:log("warn", "The 'daemonize' option has been deprecated, specify -D or -F on the command line instead.");
25e178edbc2c mod_posix: Add deprecation warning for the 'daemonize' option
Kim Alvefur <zash@zash.se>
parents: 10599
diff changeset
91 -- TODO: Write some docs and include a link in the warning.
25e178edbc2c mod_posix: Add deprecation warning for the 'daemonize' option
Kim Alvefur <zash@zash.se>
parents: 10599
diff changeset
92 end
10598
5cf481bee678 mod_posix: Support for command-line flags to override 'daemonize' config option
Matthew Wild <mwild1@gmail.com>
parents: 9763
diff changeset
93 end
2073
72784ce0c0e0 mod_posix: Switch config option to 'daemonize', fall back to 'no_daemonize' if not set, default behaviour remains the same... daemonize if mod_posix is loaded
Matthew Wild <mwild1@gmail.com>
parents: 1712
diff changeset
94
5175
fabaed7418a6 mod_posix: Remove console and stdout logging sinks before daemonizing
Kim Alvefur <zash@zash.se>
parents: 4993
diff changeset
95 local function remove_log_sinks()
12977
74b9e05af71e plugins: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents: 12297
diff changeset
96 local lm = require "prosody.core.loggingmanager";
5175
fabaed7418a6 mod_posix: Remove console and stdout logging sinks before daemonizing
Kim Alvefur <zash@zash.se>
parents: 4993
diff changeset
97 lm.register_sink_type("console", nil);
fabaed7418a6 mod_posix: Remove console and stdout logging sinks before daemonizing
Kim Alvefur <zash@zash.se>
parents: 4993
diff changeset
98 lm.register_sink_type("stdout", nil);
fabaed7418a6 mod_posix: Remove console and stdout logging sinks before daemonizing
Kim Alvefur <zash@zash.se>
parents: 4993
diff changeset
99 lm.reload_logging();
fabaed7418a6 mod_posix: Remove console and stdout logging sinks before daemonizing
Kim Alvefur <zash@zash.se>
parents: 4993
diff changeset
100 end
fabaed7418a6 mod_posix: Remove console and stdout logging sinks before daemonizing
Kim Alvefur <zash@zash.se>
parents: 4993
diff changeset
101
2073
72784ce0c0e0 mod_posix: Switch config option to 'daemonize', fall back to 'no_daemonize' if not set, default behaviour remains the same... daemonize if mod_posix is loaded
Matthew Wild <mwild1@gmail.com>
parents: 1712
diff changeset
102 if daemonize then
587
43f509a1519a Add mod_posix, fixes #5
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
103 local function daemonize_server()
5177
add9ad38208e mod_posix: Log a message explaining that we are detaching from the console
Kim Alvefur <zash@zash.se>
parents: 5175
diff changeset
104 module:log("info", "Prosody is about to detach from the console, disabling further console output");
5175
fabaed7418a6 mod_posix: Remove console and stdout logging sinks before daemonizing
Kim Alvefur <zash@zash.se>
parents: 4993
diff changeset
105 remove_log_sinks();
587
43f509a1519a Add mod_posix, fixes #5
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
106 local ok, ret = pposix.daemonize();
43f509a1519a Add mod_posix, fixes #5
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
107 if not ok then
1062
f9a1ac50782b mod_posix: Fix calls to log() (replace with module:log) and make some global accesses explicit
Matthew Wild <mwild1@gmail.com>
parents: 1061
diff changeset
108 module:log("error", "Failed to daemonize: %s", ret);
587
43f509a1519a Add mod_posix, fixes #5
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
109 elseif ret and ret > 0 then
43f509a1519a Add mod_posix, fixes #5
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
110 os.exit(0);
43f509a1519a Add mod_posix, fixes #5
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
111 else
1062
f9a1ac50782b mod_posix: Fix calls to log() (replace with module:log) and make some global accesses explicit
Matthew Wild <mwild1@gmail.com>
parents: 1061
diff changeset
112 module:log("info", "Successfully daemonized to PID %d", pposix.getpid());
991
cd0d75de8345 mod_posix: Allow logging and pidfile options to take effect without needing to daemonize. Add the ability to catch SIGTERM.
Matthew Wild <mwild1@gmail.com>
parents: 735
diff changeset
113 write_pidfile();
587
43f509a1519a Add mod_posix, fixes #5
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
114 end
43f509a1519a Add mod_posix, fixes #5
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
115 end
11062
dd3b1b9d867d mod_posix: Daemonize later
Kim Alvefur <zash@zash.se>
parents: 11047
diff changeset
116 module:hook("server-started", daemonize_server)
991
cd0d75de8345 mod_posix: Allow logging and pidfile options to take effect without needing to daemonize. Add the ability to catch SIGTERM.
Matthew Wild <mwild1@gmail.com>
parents: 735
diff changeset
117 else
1032
409f22d0430f mod_posix: Remove pidfile on exit
Matthew Wild <mwild1@gmail.com>
parents: 991
diff changeset
118 -- Not going to daemonize, so write the pid of this process
991
cd0d75de8345 mod_posix: Allow logging and pidfile options to take effect without needing to daemonize. Add the ability to catch SIGTERM.
Matthew Wild <mwild1@gmail.com>
parents: 735
diff changeset
119 write_pidfile();
587
43f509a1519a Add mod_posix, fixes #5
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
120 end
991
cd0d75de8345 mod_posix: Allow logging and pidfile options to take effect without needing to daemonize. Add the ability to catch SIGTERM.
Matthew Wild <mwild1@gmail.com>
parents: 735
diff changeset
121
3537
7bbb19804d82 mod_posix: Updated to use the new events API.
Waqas Hussain <waqas20@gmail.com>
parents: 3481
diff changeset
122 module:hook("server-stopped", remove_pidfile);