0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-23 05:13:48 +02:00

ircd: Add restart support w/ console cmd.

This commit is contained in:
Jason Volk 2019-03-02 12:25:51 -08:00
parent f0428a26b9
commit a21e03df27
5 changed files with 29 additions and 6 deletions

View file

@ -70,12 +70,14 @@ const char *const usererrstr
%s
)"};
int main(int argc, char *const *argv, const char *const *const envp)
int main(int _argc, char *const *_argv, char *const *const _envp)
try
{
umask(077); // better safe than sorry --SRB
// '-' switched arguments come first; this function incs argv and decs argc
auto argc(_argc);
auto argv(_argv), envp(_envp);
parseargs(&argc, &argv, opts);
applyargs();
@ -149,6 +151,11 @@ try
// Execution.
// Blocks until a clean exit from a quit() or an exception comes out of it.
ios.run();
// The restart flag can be set by the console command "restart" which
// calls ircd::quit() to clean break from the run() loop.
if(ircd::restart)
ircd::syscall(::execve, _argv[0], _argv, _envp);
}
catch(const ircd::user_error &e)
{

View file

@ -65,9 +65,10 @@ namespace ircd
{
struct init;
extern conf::item<bool> debugmode;
seconds uptime();
void init(boost::asio::io_context &ios, const string_view &origin, const string_view &hostname);
bool quit() noexcept;
extern conf::item<bool> restart;
extern conf::item<bool> debugmode;
}

View file

@ -21,11 +21,10 @@ namespace ircd::run
enum class level :int;
struct changed;
extern const enum level &level;
string_view reflect(const enum level &);
bool set(const enum level &);
extern const enum level &level;
}
/// An instance of this class registers itself to be called back when

View file

@ -25,6 +25,14 @@ ircd::debugmode
{ "persist", false },
};
decltype(ircd::restart)
ircd::restart
{
{ "name", "ircd.restart" },
{ "default", false },
{ "persist", false },
};
/// Sets up the IRCd and its main context, then returns without blocking.
//
/// Pass your io_context instance, it will share it with the rest of your program.

View file

@ -449,6 +449,14 @@ console_cmd__debug(opt &out, const string_view &line)
// main
//
bool
console_cmd__restart(opt &out, const string_view &line)
{
ircd::restart.set("true");
ircd::quit();
return false;
}
bool
console_cmd__die(opt &out, const string_view &line)
{