Unverified 提交 a30d27d8 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo 提交者: GitHub

mediasoup-worker prebuild: Fallback to local building if fetched binary doesn't…

mediasoup-worker prebuild: Fallback to local building if fetched binary doesn't run on current host (#1090)
上级 cf668882
# Changelog # Changelog
### Next
* mediasoup-worker prebuild: Fallback to local building if fetched binary doesn't run on current host ([PR #1090](https://github.com/versatica/mediasoup/pull/1090)).
### 3.12.0 ### 3.12.0
* Automate and publish prebuilt `mediasoup-worker` binaries ([PR #1087](https://github.com/versatica/mediasoup/pull/1087), thanks to @barlock for his work in ([PR #1083](https://github.com/versatica/mediasoup/pull/1083)). * Automate and publish prebuilt `mediasoup-worker` binaries ([PR #1087](https://github.com/versatica/mediasoup/pull/1087), thanks to @barlock for his work in ([PR #1083](https://github.com/versatica/mediasoup/pull/1083)).
......
...@@ -216,7 +216,7 @@ async function run() ...@@ -216,7 +216,7 @@ async function run()
executeCmd(`git push origin v${MAYOR_VERSION}`); executeCmd(`git push origin v${MAYOR_VERSION}`);
executeCmd(`git push origin '${PKG.version}'`); executeCmd(`git push origin '${PKG.version}'`);
logInfo('creating release in GitHub…'); logInfo('creating release in GitHub');
await octokit.repos.createRelease( await octokit.repos.createRelease(
{ {
...@@ -529,16 +529,47 @@ async function downloadPrebuiltWorker() ...@@ -529,16 +529,47 @@ async function downloadPrebuiltWorker()
{ {
// Give execution permission to the binary. // Give execution permission to the binary.
fs.chmodSync(WORKER_RELEASE_BIN_PATH, 0o775); fs.chmodSync(WORKER_RELEASE_BIN_PATH, 0o775);
resolve(true);
} }
catch (error) catch (error)
{ {
logError( logWarn(`downloadPrebuiltWorker() | failed to give execution permissions to the mediasoup-worker prebuilt binary: ${error}`);
`downloadPrebuiltWorker() | failed to download mediasoup-worker prebuilt binary: ${error}` }
);
// Let's confirm that the fetched mediasoup-worker prebuit binary does
// run in current host. This is to prevent weird issues related to
// different versions of libc in the system and so on.
// So run mediasoup-worker without the required MEDIASOUP_VERSION env and
// expect exit code 41 (see main.cpp).
logInfo(
'downloadPrebuiltWorker() | checking fetched mediasoup-worker prebuilt binary in current host'
);
resolve(false); try
{
execSync(`${WORKER_RELEASE_BIN_PATH}`, { stdio: [ 'ignore', 'ignore', 'ignore' ] });
}
catch (error)
{
if (error.status === 41)
{
resolve(true);
}
else
{
logError(
`downloadPrebuiltWorker() | fetched mediasoup-worker prebuilt binary fails to run in this host [status:${error.status}]`
);
try
{
fs.unlinkSync(WORKER_RELEASE_BIN_PATH);
}
catch (error2)
{}
resolve(false);
}
} }
}) })
.on('error', (error) => .on('error', (error) =>
...@@ -563,7 +594,7 @@ async function uploadMacArmPrebuiltWorker() ...@@ -563,7 +594,7 @@ async function uploadMacArmPrebuiltWorker()
const octokit = getOctokit(); const octokit = getOctokit();
logInfo('uploadMacArmPrebuiltWorker() | getting release info…'); logInfo('uploadMacArmPrebuiltWorker() | getting release info');
const release = await octokit.rest.repos.getReleaseByTag( const release = await octokit.rest.repos.getReleaseByTag(
{ {
...@@ -572,7 +603,7 @@ async function uploadMacArmPrebuiltWorker() ...@@ -572,7 +603,7 @@ async function uploadMacArmPrebuiltWorker()
tag : PKG.version tag : PKG.version
}); });
logInfo('uploadMacArmPrebuiltWorker() | uploading release asset…'); logInfo('uploadMacArmPrebuiltWorker() | uploading release asset');
await octokit.rest.repos.uploadReleaseAsset( await octokit.rest.repos.uploadReleaseAsset(
{ {
......
...@@ -75,7 +75,8 @@ extern "C" int mediasoup_worker_run( ...@@ -75,7 +75,8 @@ extern "C" int mediasoup_worker_run(
DepLibUV::RunLoop(); DepLibUV::RunLoop();
DepLibUV::ClassDestroy(); DepLibUV::ClassDestroy();
return 1; // 40 is a custom exit code to notify "unknown error" to the Node library.
return 40;
} }
try try
...@@ -99,7 +100,8 @@ extern "C" int mediasoup_worker_run( ...@@ -99,7 +100,8 @@ extern "C" int mediasoup_worker_run(
DepLibUV::RunLoop(); DepLibUV::RunLoop();
DepLibUV::ClassDestroy(); DepLibUV::ClassDestroy();
return 1; // 40 is a custom exit code to notify "unknown error" to the Node library.
return 40;
} }
// Initialize the Logger. // Initialize the Logger.
...@@ -130,7 +132,8 @@ extern "C" int mediasoup_worker_run( ...@@ -130,7 +132,8 @@ extern "C" int mediasoup_worker_run(
DepLibUV::RunLoop(); DepLibUV::RunLoop();
DepLibUV::ClassDestroy(); DepLibUV::ClassDestroy();
return 1; // 40 is a custom exit code to notify "unknown error" to the Node library.
return 40;
} }
MS_DEBUG_TAG(info, "starting mediasoup-worker process [version:%s]", version); MS_DEBUG_TAG(info, "starting mediasoup-worker process [version:%s]", version);
...@@ -193,7 +196,8 @@ extern "C" int mediasoup_worker_run( ...@@ -193,7 +196,8 @@ extern "C" int mediasoup_worker_run(
{ {
MS_ERROR_STD("failure exit: %s", error.what()); MS_ERROR_STD("failure exit: %s", error.what());
return 1; // 40 is a custom exit code to notify "unknown error" to the Node library.
return 40;
} }
} }
......
...@@ -18,7 +18,8 @@ int main(int argc, char* argv[]) ...@@ -18,7 +18,8 @@ int main(int argc, char* argv[])
{ {
MS_ERROR_STD("you don't seem to be my real father!"); MS_ERROR_STD("you don't seem to be my real father!");
std::_Exit(EXIT_FAILURE); // 41 is a custom exit code to notify about "missing MEDIASOUP_VERSION" env.
std::_Exit(41);
} }
const std::string version = std::getenv("MEDIASOUP_VERSION"); const std::string version = std::getenv("MEDIASOUP_VERSION");
...@@ -40,13 +41,5 @@ int main(int argc, char* argv[]) ...@@ -40,13 +41,5 @@ int main(int argc, char* argv[])
nullptr, nullptr,
nullptr); nullptr);
switch (statusCode) std::_Exit(statusCode);
{
case 0:
std::_Exit(EXIT_SUCCESS);
case 1:
std::_Exit(EXIT_FAILURE);
case 42:
std::_Exit(42);
}
} }
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论