aboutsummaryrefslogtreecommitdiffstats
path: root/util/startup.lua
Commit message (Collapse)AuthorAgeFilesLines
* util.startup: Bump expected util.pposix versionKim Alvefur6 days1-1/+1
| | | | Otherwise Prosody refuses to start.
* util.startup: Fix notifying config-reload to systemdKim Alvefur2024-04-081-1/+1
| | | | Does this event name seem backwards to anyone else?
* util.startup: Support systemd Type=notify service typeKim Alvefur2024-04-041-0/+34
| | | | | | | | | | | | | This lets Prosody report its lifecycle status to systemd, so it knows when Prosody has completed its startup, when it's reloading and shutting down. Both Type=notify and Type=notify-reload is supported Example systemd .service configuration snippet: [Service] Type=notify
* util.startup: Fix exiting on pidfile troubleKim Alvefur2024-03-271-3/+3
| | | | | | | | | | | prosody.shutdown() relies on prosody.main_thread, which has not been set yet at this point. Doing a clean shutdown might actually be harmful in case it tears down things set up by the conflicting Prosody, such as the very pidfile we were looking at. Thanks again SigmaTel71 for noticing
* util.startup: Abort before initialization of logging when started as rootKim Alvefur2024-03-241-3/+3
| | | | | Prevents creation of log files owned by the root user which could be inaccessible once started correctly.
* util.startup: Don't use not yet existent shutdown procedure when started as ↵Kim Alvefur2024-03-241-1/+1
| | | | root (thanks SigmaTel71)
* util.startup: Check root after detecting platform and reading config (thanks ↵Kim Alvefur2024-03-241-1/+1
| | | | | | | | SigmaTel71) Ensures that startup.detect_platform() runs so know whether to use the POSIX method of checking the current user or something else. Also after reading the config so we know whether the root override setting is set.
* mod_posix: Move everything to util.startupKim Alvefur2024-03-231-9/+108
| | | | | | | | | | | | | | | | | | | This allows greater control over the order of events. Notably, the internal ordering between daemonization, initialization of libunbound and setup of signal handling is sensitive. libunbound starts a separate thread for processing DNS requests. If this thread is started before signal handling has been set up, it will not inherit the signal handlers and instead behave as it would have before signal handlers were set up, i.e. cause the whole process to immediately exit. libunbound is usually initialized on the first DNS request, usually triggered by an outgoing s2s connection attempt. If daemonization happens before signals have been set up, signals may not be processed at all.
* util.startup: Back out 598df17b8ebbKim Alvefur2024-03-101-1/+1
| | | | | | | | Broke signal handling again, such that an early s2s connection results in libunbound catching signals and getting Prosody killed on e.g. SIGHUP This returns to the situation where prosody --daemonize does not respond to signals.
* util.startup: Hook signals after daemonizationKim Alvefur2024-03-061-1/+1
| | | | | | signalfds stop working with epoll after forking hooking signals later should not affect anything
* util.startup: Fix firing of USR1/2 eventsKim Alvefur2024-03-021-2/+2
|
* mod_posix: Move POSIX signal handling into util.startup to avoid raceKim Alvefur2024-03-021-0/+43
| | | | | | | | | | 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
* util.startup: Expose core.features.available as prosody.featuresMatthew Wild2024-02-221-0/+2
| | | | for convenience.
* util.startup: Use prosody. module namespaceKim Alvefur2023-11-241-1/+1
| | | | Maybe we need some sort of lint for this?
* util.startup: Attempt to bring some order to startup/shutdown with util.fsmMatthew Wild2023-11-071-10/+41
|
* renamening: Fix newly added imports to use the new namespaceKim Alvefur2023-06-181-2/+2
|
* util.startup: Record current version in a metricKim Alvefur2023-05-311-1/+1
| | | | | Useful to have this info available when juggling metrics, e.g. to see if things changed between versions.
* util.startup: Remove componentmanager backwards compatibilityKim Alvefur2023-05-311-5/+0
| | | | Module was removed in 0.8.0 in c52b06de9b27
* util.startup: Add prosody.started promise to easily execute code after startupMatthew Wild2023-04-011-3/+14
| | | | | | | | | To avoid a race where server-started fires before the promise function body is run (on next tick), I moved server-started to fire on the next tick, which seems sensible anyway. Errors are logged, I'm not sure if we ought to be doing something more here. I'm sure we'll find out.
* util.startup: Tweak function string representationKim Alvefur2023-03-261-1/+1
| | | | | Mostly in order to avoid triggering the XML syntax highlighting in the console logger.
* util: Prefix module imports with prosody namespaceKim Alvefur2023-03-171-39/+39
|
* Merge 0.12->trunkKim Alvefur2023-01-221-1/+1
|\
| * util.startup: Close state on exit to ensure GC finalizers are calledKim Alvefur2023-01-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Ensures a last round of garbage collection and that finalizers are called. Fixes things like proper closing of SQLite3 state. There are more calls to os.exit() but most of them exit with an error or in a case where a final GC sweep might not matter as much. It would be nice if this was the default. Calling util.statup.exit() everywhere may be sensible, but would be more involved, requiring imports everywhere.
* | util.mathcompat: Module to ease reuse of math.type()Kim Alvefur2022-10-201-10/+1
| | | | | | | | | | Mostly to ensure it is available during tests, as util.startup is not invoked there
* | util.startup: Provide a common Lua 5.3+ math.type() for Lua 5.2Kim Alvefur2022-10-191-0/+14
|/ | | | Code deduplication
* util.startup: Ensure import() is available in prosodyctl (thanks keyzer)Kim Alvefur2022-10-201-1/+1
| | | | | Fixes error in mod_authz_internal due to import() being unavailable as it was only loaded in Prosody proper
* util.startup: Fix async waiting for last shutdown stepsKim Alvefur2022-06-141-1/+5
| | | | | | | | | | | Observed problem: When shutting down prosody would immediately exit after waiting for s2s connections to close, skipping the last cleanup events and reporting the exit reason and code. This happens because prosody.main_thread is in a waiting state and queuing startup.shutdown is dispatched trough the main loop via nexttick, but since the main loop was no longer running at that point it proceeded to the end of the prosody script and exited there.
* util.startup: Show error for unrecognized arguments passed to 'prosody' ↵Matthew Wild2022-03-211-6/+13
| | | | (fixes #1722)
* prosody: Move last cleanup and shutdown code into util.startupKim Alvefur2019-01-011-0/+16
|
* util.startup: Enable DANE in http client library with use_daneKim Alvefur2022-02-051-0/+1
|
* util.startup: Teach prosodyctl to be completely --silentKim Alvefur2021-11-281-0/+3
|
* util.startup: Teach prosodyctl to be --quiet as complement to --verboseKim Alvefur2021-11-281-1/+7
| | | | | | | | Original motivation was tiresome warnings about Lua 5.4 not being supported yet. Can still be handy to tweak log level, e.g. to prevent logging to interfere with command output.
* util.startup: Allow supplying an argument parsing settingsKim Alvefur2022-01-091-2/+2
| | | | | | The 'prosody' global is not global this early so there was no way to override the process type field or argument parsing settings from outside, e.g. from the migrator.
* util.startup: Initialize util.async at startupMatthew Wild2021-11-291-0/+9
|
* util.startup: Integrate util.promise with net.server main loopKim Alvefur2019-01-051-0/+8
|
* util.startup: Understand -h, -? as --help in prosodyctl but ignoreKim Alvefur2021-10-251-1/+1
| | | | | prosodyctl -h showing an error was not very helpful, especially since prosodyctl shows its help for any unknown (or none) command.
* util.startup: Show brief usage on `prosody -h|-?|--help`Kim Alvefur2021-10-251-1/+8
| | | | | Seems more suitable than asking if prosodyctl was meant to be used, or going ahead and starting.
* util.startup: Skip config readability check in migrator (thanks eTaurus)Kim Alvefur2021-10-231-1/+1
| | | | | | This field is empty for reasons when invoked by prosody-migrator, which threw an error: > bad argument #1 to 'open' (string expected, got nil)
* util.startup: Only ask if 'prosodyctl' was meant instead of 'prosody' (fix ↵Kim Alvefur2021-10-121-1/+3
| | | | #1692)
* util.startup: Allow separate command line argument settings for prosody and ↵Kim Alvefur2021-09-301-6/+11
| | | | | | | prosodyctl Makes it clearer that prosody does not take -v atm, as well as how prosodyctl does not take the demonization flags.
* prosodyctl: Add support for -v/--verbose to enable debug loggingKim Alvefur2021-09-301-2/+4
| | | | More convenient than the environment variable.
* Merge 0.11->trunkMatthew Wild2021-05-131-1/+7
|\
| * util.startup: Set more aggressive defaults for GCMatthew Wild2021-05-071-1/+7
| | | | | | | | | | | | | | | | | | Testing has demonstrated that the default GC parameters are not sufficient to prevent runaway memory growth when running under Lua 5.2 and Lua 5.3. Setting the GC speed to 500 was tested on Lua versions 5.1->5.4 and did not display unbounded memory growth.
| * util.startup: Configure the GC on startup, using the config or built-in defaultsMatthew Wild2020-06-151-0/+17
| |
* | util.startup: Make installer_plugin_path relative to data directoryKim Alvefur2021-01-241-3/+2
| | | | | | | | | | | | Having it relative to current working directory is problematic since this depends on how Prosody was started and changes to the data directory during startup (but after this point).
* | util.startup: Don't create installer plugin path (as root)Kim Alvefur2021-01-241-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Since this runs before dropping root, the directory ends up being owned by root, resulting in luarocks failing to install anything, since by then it would be running as the prosody user. luarocks creates this directory if needed, so creating it during startup is not necessary. One potential issue is if the directory is somewhere where Prosody can't write, but then you will simply have to create it yourself with the appropriate permissions.
* | util.startup: Handle missing nparams field from debug info (not present in 5.1)Matthew Wild2020-10-111-2/+3
| |
* | util.startup: Include arguments in function string representationKim Alvefur2020-10-091-2/+8
| | | | | | | | | | | | | | Improves usability of the console when digging around the internals. No specific rationale for the function<file:line>(args) format, it looked best of the variants I tried.
* | util.startup: Retrieve less data for function string representationKim Alvefur2020-10-091-1/+1
| | | | | | | | debug.getinfo(f) collects more info than what is needed here.
* | util.startup: Save the path used by the installer to prosody.pathsKim Alvefur2020-10-071-0/+1
| | | | | | | | | | | | Makes it easier for other parts of the code to use this for things, such as determining whether a certain module is from this path or from elsewhere.