add interactive shell

This commit is contained in:
Martin Michelsen
2019-01-29 00:17:04 -08:00
parent d0408246d3
commit f3842b49f3
10 changed files with 274 additions and 15 deletions
+17 -5
View File
@@ -15,6 +15,7 @@
#include "Server.hh"
#include "FileContentsCache.hh"
#include "Text.hh"
#include "Shell.hh"
using namespace std;
@@ -112,6 +113,12 @@ void populate_state_from_config(shared_ptr<ServerState> s,
} catch (const JSONObject::key_error&) {
s->run_dns_server = true;
}
try {
s->run_interactive_shell = d.at("RunInteractiveShell")->as_bool();
} catch (const JSONObject::key_error&) {
s->run_interactive_shell = true;
}
}
@@ -165,10 +172,16 @@ int main(int argc, char* argv[]) {
}
game_server->start();
for (;;) {
sigset_t s;
sigemptyset(&s);
sigsuspend(&s);
if (state->run_interactive_shell) {
log(INFO, "starting interactive shell");
run_shell(state);
} else {
for (;;) {
sigset_t s;
sigemptyset(&s);
sigsuspend(&s);
}
}
log(INFO, "waiting for servers to terminate");
@@ -179,4 +192,3 @@ int main(int argc, char* argv[]) {
return 0;
}