Hermes
0.7.0
Linux game streaming host
Toggle main menu visibility
Loading...
Searching...
No Matches
entry_handler.cpp
Go to the documentation of this file.
1
5
// standard includes
6
#include <csignal>
7
#include <format>
8
#include <iostream>
9
#include <thread>
10
11
// local includes
12
#include "
config.h
"
13
#include "
confighttp.h
"
14
#include "
entry_handler.h
"
15
#include "
globals.h
"
16
#include "
httpcommon.h
"
17
#include "
logging.h
"
18
#include "
network.h
"
19
#include "
platform/common.h
"
20
21
using namespace
std::literals;
22
23
void
launch_ui
(
const
std::optional<std::string> &path) {
24
std::string url = std::format(
"https://localhost:{}"
,
static_cast<
int
>
(
net::map_port
(confighttp::PORT_HTTPS)));
25
if
(path) {
26
url += *path;
27
}
28
platf::open_url
(url);
29
}
30
31
namespace
args
{
32
int
creds
(
const
char
*name,
int
argc,
char
*argv[]) {
33
if
(argc < 2 || argv[0] ==
"help"
sv || argv[1] ==
"help"
sv) {
34
help
(name);
35
}
36
37
http::save_user_creds(config::sunshine.credentials_file, argv[0], argv[1]);
38
39
return
0;
40
}
41
42
int
help
(
const
char
*name) {
43
logging::print_help
(name);
44
return
0;
45
}
46
47
int
version
() {
48
// version was already logged at startup
49
return
0;
50
}
51
52
}
// namespace args
53
54
namespace
lifetime
{
55
char
**argv;
56
std::atomic_int desired_exit_code;
57
58
void
exit_sunshine
(
int
exit_code,
bool
async) {
59
// Store the exit code of the first exit_sunshine() call
60
int
zero = 0;
61
desired_exit_code.compare_exchange_strong(zero, exit_code);
62
63
// Raise SIGINT to start termination
64
std::raise(SIGINT);
65
66
// Termination will happen asynchronously, but the caller may
67
// have wanted synchronous behavior.
68
while
(!async) {
69
std::this_thread::sleep_for(1s);
70
}
71
}
72
73
void
debug_trap
() {
74
std::raise(SIGTRAP);
75
// If debug trap still doesn't work, abort
76
abort();
77
}
78
79
char
**
get_argv
() {
80
return
argv;
81
}
82
}
// namespace lifetime
83
84
void
log_publisher_data
() {
85
BOOST_LOG(info) <<
"Package Publisher: "
sv << HERMES_PUBLISHER_NAME;
86
BOOST_LOG(info) <<
"Publisher Website: "
sv << HERMES_PUBLISHER_WEBSITE;
87
BOOST_LOG(info) <<
"Get support: "
sv << HERMES_PUBLISHER_ISSUE_URL;
88
}
common.h
Declarations for common platform specific utilities.
platf::open_url
void open_url(const std::string &url)
Open a url in the default web browser.
Definition
misc.cpp:546
config.h
Declarations for the configuration of Sunshine.
confighttp.h
Declarations for the Web UI Config HTTP server.
launch_ui
void launch_ui(const std::optional< std::string > &path)
Launch the Web UI.
Definition
entry_handler.cpp:23
log_publisher_data
void log_publisher_data()
Log the publisher metadata provided from CMake.
Definition
entry_handler.cpp:84
entry_handler.h
Declarations for entry handling functions.
globals.h
Declarations for globally accessible variables and functions.
httpcommon.h
Declarations for common HTTP.
logging.h
Declarations for logging related functions.
args
Functions for handling command line arguments.
Definition
entry_handler.cpp:31
args::creds
int creds(const char *name, int argc, char *argv[])
Reset the user credentials.
Definition
entry_handler.cpp:32
args::version
int version()
Print the version to stdout, then exit.
Definition
entry_handler.cpp:47
args::help
int help(const char *name)
Print help to stdout, then exit.
Definition
entry_handler.cpp:42
lifetime
Functions for handling the lifetime of Sunshine.
Definition
entry_handler.cpp:54
lifetime::debug_trap
void debug_trap()
Breaks into the debugger or terminates Sunshine if no debugger is attached.
Definition
entry_handler.cpp:73
lifetime::exit_sunshine
void exit_sunshine(int exit_code, bool async)
Terminates Sunshine gracefully with the provided exit code.
Definition
entry_handler.cpp:58
lifetime::get_argv
char ** get_argv()
Get the argv array passed to main().
Definition
entry_handler.cpp:79
logging::print_help
void print_help(const char *name)
Print help to stdout.
Definition
logging.cpp:211
net::map_port
std::uint16_t map_port(int port)
Map a specified port based on the base port.
Definition
network.cpp:350
network.h
Declarations for networking related functions.
src
entry_handler.cpp
Generated by
1.18.0