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

Properly handle signals.

上级 79c8493b
......@@ -61,6 +61,9 @@ class Server
debug('constructor() | [worker parameters:"%s"]', parameters.join(' '));
// Add the server to the set
servers.add(this);
// Create mediasoup-worker child processes
for (let i = 1; i <= numWorkers; i++)
{
......@@ -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) =>
......@@ -109,9 +112,6 @@ class Server
// Add the worker to the map
this._workers.set(workerId, worker);
}
// Add the server to the set
servers.add(this);
}
close()
......
......@@ -34,6 +34,18 @@ int main(int argc, char* argv[])
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);
#if defined(MS_LITTLE_ENDIAN)
......@@ -50,18 +62,6 @@ int main(int argc, char* argv[])
MS_WARN("cannot determine whether the architecture is 32 or 64 bits");
#endif
try
{
Settings::SetConfiguration(argc, argv);
}
catch (const MediaSoupError &error)
{
MS_EXIT_FAILURE("%s", error.what());
}
// Print configuration.
Settings::PrintConfiguration();
try
{
init();
......@@ -103,12 +103,9 @@ void ignoreSignals()
int err;
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 =
{
{ "INT", SIGINT },
{ "TERM", SIGTERM },
{ "PIPE", SIGPIPE },
{ "HUP", SIGHUP },
{ "ALRM", SIGALRM },
{ "USR1", SIGUSR2 },
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论