0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 08:12:37 +01:00

charybdis: Various improvements / fixes to console etc.

This commit is contained in:
Jason Volk 2017-08-23 15:46:35 -06:00
parent 60a22a0216
commit 2e0d0467ee
2 changed files with 36 additions and 14 deletions

View file

@ -84,7 +84,6 @@ int main(int argc, char *const *argv)
try
{
umask(077); // better safe than sorry --SRB
parseargs(&argc, &argv, opts);
if(!startup_checks())
return 1;
@ -95,9 +94,24 @@ try
return 0;
}
const std::string confpath(configfile?: fs::get(fs::IRCD_CONF));
// Determine the configuration file from either the user's command line
// argument or fall back to the default.
const std::string confpath
{
configfile?: fs::get(fs::IRCD_CONF)
};
// Associates libircd with our io_service and posts the initial routines
// to that io_service. Execution of IRCd will then occur during ios::run()
ircd::init(*ios, confpath);
// libircd does no signal handling (or at least none that you ever have to
// care about); reaction to all signals happens out here instead. Handling
// is done properly through the io_service which registers the handler for
// the platform and then safely posts the received signal to the io_service
// event loop. This means we lose the true instant hardware-interrupt gratitude
// of signals but with the benefit of unconditional safety and cross-
// platformness with windows etc.
sigs.add(SIGHUP);
sigs.add(SIGINT);
sigs.add(SIGTSTP);
@ -105,18 +119,26 @@ try
sigs.add(SIGTERM);
sigs.add(SIGUSR1);
sigs.add(SIGUSR2);
ircd::at_main_exit([]
{
// Entered when IRCd's main context has finished. ios.run() won't
// return because our signal handler out here is still using it.
sigs.cancel();
});
sigs.async_wait(sigfd_handler);
// Because we registered signal handlers with the io_service, ios->run()
// is now shared between those handlers and libircd. This means the run()
// won't return even if ircd::stop() is called. We use the callback to then
// cancel the handlers allowing run() to return and the program to exit.
ircd::at_main_exit([]
{
// Entered when IRCd's main context has finished.
sigs.cancel();
});
// If the user wants to immediately drop to a command line without having to
// send a ctrl-c for it, that is provided here.
if(cmdline)
console_spawn();
ios->run(); // Blocks until a clean exit or an exception comes out of it.
// Execution.
// Blocks until a clean exit from a stop() or an exception comes out of it.
ios->run();
}
catch(const ircd::user_error &e)
{
@ -156,6 +178,7 @@ void print_version()
#endif
printf("VERSION :boost %d\n", BOOST_VERSION);
printf("VERSION :RocksDB %s\n", ircd::db::version);
}
bool startup_checks()

View file

@ -252,7 +252,7 @@ try
const auto args(tokens_after(line, " ", 0));
const params token{args, " ", {"host", "port"}};
const std::string host{token.at(0, "127.0.0.1"s)};
const auto port{token.at<uint16_t>(1, 6667)};
const auto port{token.at<uint16_t>(1, 8448)};
moi = new m::session{{host, port}};
break;
}
@ -298,14 +298,13 @@ try
}
const auto args(tokens_after(line, " ", 0));
const params token{args, " ", {"username", "pass"}};
const params token{args, " ", {"username", "password"}};
m::request request
{
"POST", "_matrix/client/r0/register", {},
"POST", "_matrix/client/r0/register?kind=user", {},
{
{ "username", token.at(0) },
{ "pass", token.at(1) },
{ "password", token.at(1) },
{
"auth",
@ -332,7 +331,7 @@ try
}
const auto args(tokens_after(line, " ", 0));
const params token{args, " ", {"user", "pass"}};
const params token{args, " ", {"username", "password"}};
m::request request
{