Mercurial > prosody-hg
comparison plugins/mod_posix.lua @ 12297:249eb306f668
mod_posix: Run signal handlers in the startup thread
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 06 Oct 2021 14:50:47 +0200 |
| parents | 7fe2fbfbdb1c |
| children | 74b9e05af71e |
comparison
equal
deleted
inserted
replaced
| 12296:49ebac8a5260 | 12297:249eb306f668 |
|---|---|
| 128 -- Set signal handlers | 128 -- Set signal handlers |
| 129 if have_signal then | 129 if have_signal then |
| 130 module:add_timer(0, function () | 130 module:add_timer(0, function () |
| 131 signal.signal("SIGTERM", function () | 131 signal.signal("SIGTERM", function () |
| 132 module:log("warn", "Received SIGTERM"); | 132 module:log("warn", "Received SIGTERM"); |
| 133 prosody.unlock_globals(); | 133 prosody.main_thread:run(function () |
| 134 prosody.shutdown("Received SIGTERM"); | 134 prosody.unlock_globals(); |
| 135 prosody.lock_globals(); | 135 prosody.shutdown("Received SIGTERM"); |
| 136 prosody.lock_globals(); | |
| 137 end); | |
| 136 end); | 138 end); |
| 137 | 139 |
| 138 signal.signal("SIGHUP", function () | 140 signal.signal("SIGHUP", function () |
| 139 module:log("info", "Received SIGHUP"); | 141 module:log("info", "Received SIGHUP"); |
| 140 prosody.reload_config(); | 142 prosody.main_thread:run(function () |
| 143 prosody.reload_config(); | |
| 144 end); | |
| 141 -- this also reloads logging | 145 -- this also reloads logging |
| 142 end); | 146 end); |
| 143 | 147 |
| 144 signal.signal("SIGINT", function () | 148 signal.signal("SIGINT", function () |
| 145 module:log("info", "Received SIGINT"); | 149 module:log("info", "Received SIGINT"); |
| 146 prosody.unlock_globals(); | 150 prosody.main_thread:run(function () |
| 147 prosody.shutdown("Received SIGINT"); | 151 prosody.unlock_globals(); |
| 148 prosody.lock_globals(); | 152 prosody.shutdown("Received SIGINT"); |
| 153 prosody.lock_globals(); | |
| 154 end); | |
| 149 end); | 155 end); |
| 150 | 156 |
| 151 signal.signal("SIGUSR1", function () | 157 signal.signal("SIGUSR1", function () |
| 152 module:log("info", "Received SIGUSR1"); | 158 module:log("info", "Received SIGUSR1"); |
| 153 module:fire_event("signal/SIGUSR1"); | 159 module:fire_event("signal/SIGUSR1"); |
