159 |
159 |
160 module:hook("server-stopped", remove_pidfile); |
160 module:hook("server-stopped", remove_pidfile); |
161 |
161 |
162 -- Set signal handlers |
162 -- Set signal handlers |
163 if have_signal then |
163 if have_signal then |
164 signal.signal("SIGTERM", function () |
164 module:add_timer(0, function () |
165 module:log("warn", "Received SIGTERM"); |
165 signal.signal("SIGTERM", function () |
166 prosody.unlock_globals(); |
166 module:log("warn", "Received SIGTERM"); |
167 prosody.shutdown("Received SIGTERM"); |
167 prosody.unlock_globals(); |
168 prosody.lock_globals(); |
168 prosody.shutdown("Received SIGTERM"); |
169 end); |
169 prosody.lock_globals(); |
|
170 end); |
170 |
171 |
171 signal.signal("SIGHUP", function () |
172 signal.signal("SIGHUP", function () |
172 module:log("info", "Received SIGHUP"); |
173 module:log("info", "Received SIGHUP"); |
173 prosody.reload_config(); |
174 prosody.reload_config(); |
174 prosody.reopen_logfiles(); |
175 prosody.reopen_logfiles(); |
175 end); |
176 end); |
176 |
177 |
177 signal.signal("SIGINT", function () |
178 signal.signal("SIGINT", function () |
178 module:log("info", "Received SIGINT"); |
179 module:log("info", "Received SIGINT"); |
179 prosody.unlock_globals(); |
180 prosody.unlock_globals(); |
180 prosody.shutdown("Received SIGINT"); |
181 prosody.shutdown("Received SIGINT"); |
181 prosody.lock_globals(); |
182 prosody.lock_globals(); |
|
183 end); |
182 end); |
184 end); |
183 end |
185 end |