mirror of
https://github.com/matrix-construct/construct
synced 2024-06-16 00:48:26 +02:00
ircd: Add restart support w/ console cmd.
This commit is contained in:
parent
f0428a26b9
commit
a21e03df27
|
@ -70,12 +70,14 @@ const char *const usererrstr
|
||||||
%s
|
%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
|
try
|
||||||
{
|
{
|
||||||
umask(077); // better safe than sorry --SRB
|
umask(077); // better safe than sorry --SRB
|
||||||
|
|
||||||
// '-' switched arguments come first; this function incs argv and decs argc
|
// '-' switched arguments come first; this function incs argv and decs argc
|
||||||
|
auto argc(_argc);
|
||||||
|
auto argv(_argv), envp(_envp);
|
||||||
parseargs(&argc, &argv, opts);
|
parseargs(&argc, &argv, opts);
|
||||||
applyargs();
|
applyargs();
|
||||||
|
|
||||||
|
@ -149,6 +151,11 @@ try
|
||||||
// Execution.
|
// Execution.
|
||||||
// Blocks until a clean exit from a quit() or an exception comes out of it.
|
// Blocks until a clean exit from a quit() or an exception comes out of it.
|
||||||
ios.run();
|
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)
|
catch(const ircd::user_error &e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,9 +65,10 @@ namespace ircd
|
||||||
{
|
{
|
||||||
struct init;
|
struct init;
|
||||||
|
|
||||||
extern conf::item<bool> debugmode;
|
|
||||||
|
|
||||||
seconds uptime();
|
seconds uptime();
|
||||||
void init(boost::asio::io_context &ios, const string_view &origin, const string_view &hostname);
|
void init(boost::asio::io_context &ios, const string_view &origin, const string_view &hostname);
|
||||||
bool quit() noexcept;
|
bool quit() noexcept;
|
||||||
|
|
||||||
|
extern conf::item<bool> restart;
|
||||||
|
extern conf::item<bool> debugmode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,10 @@ namespace ircd::run
|
||||||
enum class level :int;
|
enum class level :int;
|
||||||
struct changed;
|
struct changed;
|
||||||
|
|
||||||
extern const enum level &level;
|
|
||||||
|
|
||||||
string_view reflect(const enum level &);
|
string_view reflect(const enum level &);
|
||||||
|
|
||||||
bool set(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
|
/// An instance of this class registers itself to be called back when
|
||||||
|
|
|
@ -25,6 +25,14 @@ ircd::debugmode
|
||||||
{ "persist", false },
|
{ "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.
|
/// 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.
|
/// Pass your io_context instance, it will share it with the rest of your program.
|
||||||
|
|
|
@ -449,6 +449,14 @@ console_cmd__debug(opt &out, const string_view &line)
|
||||||
// main
|
// main
|
||||||
//
|
//
|
||||||
|
|
||||||
|
bool
|
||||||
|
console_cmd__restart(opt &out, const string_view &line)
|
||||||
|
{
|
||||||
|
ircd::restart.set("true");
|
||||||
|
ircd::quit();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
console_cmd__die(opt &out, const string_view &line)
|
console_cmd__die(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue