Merge pull request #650 from cgutman/term_logging_feedback
Remove Enter prompt on exit and make log levels for execution messages consistent
This commit is contained in:
25
src/main.cpp
25
src/main.cpp
@@ -158,8 +158,6 @@ LRESULT CALLBACK SessionMonitorWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, L
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
util::TaskPool::task_id_t force_shutdown = nullptr;
|
util::TaskPool::task_id_t force_shutdown = nullptr;
|
||||||
|
|
||||||
bool shutdown_by_interrupt = false;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Wait as long as possible to terminate Sunshine.exe during logoff/shutdown
|
// Wait as long as possible to terminate Sunshine.exe during logoff/shutdown
|
||||||
SetProcessShutdownParameters(0x100, SHUTDOWN_NORETRY);
|
SetProcessShutdownParameters(0x100, SHUTDOWN_NORETRY);
|
||||||
@@ -204,26 +202,6 @@ int main(int argc, char *argv[]) {
|
|||||||
window_thread.detach();
|
window_thread.detach();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto exit_guard = util::fail_guard([&shutdown_by_interrupt, &force_shutdown]() {
|
|
||||||
if(!shutdown_by_interrupt) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
// If this is running from a service with no console window, don't wait for user input to exit
|
|
||||||
if(GetConsoleWindow() == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
task_pool.cancel(force_shutdown);
|
|
||||||
|
|
||||||
std::cout << "Sunshine exited: Press enter to continue"sv << std::endl;
|
|
||||||
|
|
||||||
std::string _;
|
|
||||||
std::getline(std::cin, _);
|
|
||||||
});
|
|
||||||
|
|
||||||
mail::man = std::make_shared<safe::mail_raw_t>();
|
mail::man = std::make_shared<safe::mail_raw_t>();
|
||||||
|
|
||||||
if(config::parse(argc, argv)) {
|
if(config::parse(argc, argv)) {
|
||||||
@@ -304,7 +282,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
// Create signal handler after logging has been initialized
|
// Create signal handler after logging has been initialized
|
||||||
auto shutdown_event = mail::man->event<bool>(mail::shutdown);
|
auto shutdown_event = mail::man->event<bool>(mail::shutdown);
|
||||||
on_signal(SIGINT, [&shutdown_by_interrupt, &force_shutdown, shutdown_event]() {
|
on_signal(SIGINT, [&force_shutdown, shutdown_event]() {
|
||||||
BOOST_LOG(info) << "Interrupt handler called"sv;
|
BOOST_LOG(info) << "Interrupt handler called"sv;
|
||||||
|
|
||||||
auto task = []() {
|
auto task = []() {
|
||||||
@@ -314,7 +292,6 @@ int main(int argc, char *argv[]) {
|
|||||||
};
|
};
|
||||||
force_shutdown = task_pool.pushDelayed(task, 10s).task_id;
|
force_shutdown = task_pool.pushDelayed(task, 10s).task_id;
|
||||||
|
|
||||||
shutdown_by_interrupt = true;
|
|
||||||
shutdown_event->raise(true);
|
shutdown_event->raise(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ int proc_t::execute(int app_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(proc.cmd.empty()) {
|
if(proc.cmd.empty()) {
|
||||||
BOOST_LOG(debug) << "Executing [Desktop]"sv;
|
BOOST_LOG(info) << "Executing [Desktop]"sv;
|
||||||
placebo = true;
|
placebo = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -202,7 +202,7 @@ void proc_t::terminate() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_LOG(debug) << "Executing: ["sv << cmd << ']';
|
BOOST_LOG(info) << "Executing: ["sv << cmd << ']';
|
||||||
|
|
||||||
auto ret = exe_with_full_privs(cmd, _env, _pipe, ec);
|
auto ret = exe_with_full_privs(cmd, _env, _pipe, ec);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user