提交 c7be8174 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Properly handle signals.

上级 79c8493b
...@@ -61,6 +61,9 @@ class Server ...@@ -61,6 +61,9 @@ class Server
debug('constructor() | [worker parameters:"%s"]', parameters.join(' ')); debug('constructor() | [worker parameters:"%s"]', parameters.join(' '));
// Add the server to the set
servers.add(this);
// Create mediasoup-worker child processes // Create mediasoup-worker child processes
for (let i = 1; i <= numWorkers; i++) for (let i = 1; i <= numWorkers; i++)
{ {
...@@ -96,9 +99,9 @@ class Server ...@@ -96,9 +99,9 @@ class Server
}); });
}); });
worker.on('exit', (code) => worker.on('exit', (code, signal) =>
{ {
debug('worker process closed [workerId:%s, code:%s]', worker.workerId, code); debug('worker process closed [workerId:%s, code:%s, signal:%s]', worker.workerId, code, signal);
}); });
worker.on('error', (error) => worker.on('error', (error) =>
...@@ -109,9 +112,6 @@ class Server ...@@ -109,9 +112,6 @@ class Server
// Add the worker to the map // Add the worker to the map
this._workers.set(workerId, worker); this._workers.set(workerId, worker);
} }
// Add the server to the set
servers.add(this);
} }
close() close()
......
...@@ -34,6 +34,18 @@ int main(int argc, char* argv[]) ...@@ -34,6 +34,18 @@ int main(int argc, char* argv[])
Logger::Init(id); Logger::Init(id);
try
{
Settings::SetConfiguration(argc, argv);
}
catch (const MediaSoupError &error)
{
MS_EXIT_FAILURE("%s", error.what());
}
// Print configuration.
Settings::PrintConfiguration();
MS_INFO("starting " MS_PROCESS_NAME); MS_INFO("starting " MS_PROCESS_NAME);
#if defined(MS_LITTLE_ENDIAN) #if defined(MS_LITTLE_ENDIAN)
...@@ -50,18 +62,6 @@ int main(int argc, char* argv[]) ...@@ -50,18 +62,6 @@ int main(int argc, char* argv[])
MS_WARN("cannot determine whether the architecture is 32 or 64 bits"); MS_WARN("cannot determine whether the architecture is 32 or 64 bits");
#endif #endif
try
{
Settings::SetConfiguration(argc, argv);
}
catch (const MediaSoupError &error)
{
MS_EXIT_FAILURE("%s", error.what());
}
// Print configuration.
Settings::PrintConfiguration();
try try
{ {
init(); init();
...@@ -103,12 +103,9 @@ void ignoreSignals() ...@@ -103,12 +103,9 @@ void ignoreSignals()
int err; int err;
struct sigaction act; struct sigaction act;
// NOTE: Here we ignore also signals that will be later handled in Loop
// (the libuv signal handler overrides it).
std::map<std::string, int> ignored_signals = std::map<std::string, int> ignored_signals =
{ {
{ "INT", SIGINT }, { "PIPE", SIGPIPE },
{ "TERM", SIGTERM },
{ "HUP", SIGHUP }, { "HUP", SIGHUP },
{ "ALRM", SIGALRM }, { "ALRM", SIGALRM },
{ "USR1", SIGUSR2 }, { "USR1", SIGUSR2 },
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论