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

Export workerBin absolute path (#1123)

上级 dbc377cd
# Changelog # Changelog
### Next
* Export `workerBin` absolute path ([PR #1123](https://github.com/versatica/mediasoup/pull/1123)).
### 3.12.7 ### 3.12.7
* `SimulcastConsumer`: Fix lack of "layerschange" event when all streams in the producer die ([PR #1122](https://github.com/versatica/mediasoup/pull/1122)). * `SimulcastConsumer`: Fix lack of "layerschange" event when all streams in the producer die ([PR #1122](https://github.com/versatica/mediasoup/pull/1122)).
......
...@@ -126,7 +126,7 @@ In order to instruct the mediasoup Node.js module to use the `Debug` mediasoup-w ...@@ -126,7 +126,7 @@ In order to instruct the mediasoup Node.js module to use the `Debug` mediasoup-w
MEDIASOUP_BUILDTYPE=Debug node myapp.js MEDIASOUP_BUILDTYPE=Debug node myapp.js
``` ```
If the "MEDIASOUP_WORKER_BIN" environment variable is set, mediasoup will use the it as mediasoup-worker binary and **won't** compile the binary: If the "MEDIASOUP_WORKER_BIN" environment variable is set (it must be an absolute file path), mediasoup will use the it as mediasoup-worker binary and **won't** compile the binary:
```bash ```bash
MEDIASOUP_WORKER_BIN="/home/xxx/src/foo/mediasoup-worker" node myapp.js MEDIASOUP_WORKER_BIN="/home/xxx/src/foo/mediasoup-worker" node myapp.js
......
...@@ -195,7 +195,7 @@ export type WorkerObserverEvents = ...@@ -195,7 +195,7 @@ export type WorkerObserverEvents =
// If env MEDIASOUP_WORKER_BIN is given, use it as worker binary. // If env MEDIASOUP_WORKER_BIN is given, use it as worker binary.
// Otherwise if env MEDIASOUP_BUILDTYPE is 'Debug' use the Debug binary. // Otherwise if env MEDIASOUP_BUILDTYPE is 'Debug' use the Debug binary.
// Otherwise use the Release binary. // Otherwise use the Release binary.
const workerBin = process.env.MEDIASOUP_WORKER_BIN export const workerBin = process.env.MEDIASOUP_WORKER_BIN
? process.env.MEDIASOUP_WORKER_BIN ? process.env.MEDIASOUP_WORKER_BIN
: process.env.MEDIASOUP_BUILDTYPE === 'Debug' : process.env.MEDIASOUP_BUILDTYPE === 'Debug'
? path.join(__dirname, '..', '..', 'worker', 'out', 'Debug', 'mediasoup-worker') ? path.join(__dirname, '..', '..', 'worker', 'out', 'Debug', 'mediasoup-worker')
......
import { Logger } from './Logger'; import { Logger } from './Logger';
import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import { EnhancedEventEmitter } from './EnhancedEventEmitter';
import { Worker, WorkerSettings } from './Worker'; import { workerBin, Worker, WorkerSettings } from './Worker';
import * as utils from './utils'; import * as utils from './utils';
import { supportedRtpCapabilities } from './supportedRtpCapabilities'; import { supportedRtpCapabilities } from './supportedRtpCapabilities';
import { RtpCapabilities } from './RtpParameters'; import { RtpCapabilities } from './RtpParameters';
...@@ -36,6 +36,11 @@ const observer = new EnhancedEventEmitter<ObserverEvents>(); ...@@ -36,6 +36,11 @@ const observer = new EnhancedEventEmitter<ObserverEvents>();
*/ */
export { observer }; export { observer };
/**
* Full path of the mediasoup-worker binary.
*/
export { workerBin };
/** /**
* Create a Worker. * Create a Worker.
*/ */
......
...@@ -11,6 +11,17 @@ let worker: mediasoup.types.Worker; ...@@ -11,6 +11,17 @@ let worker: mediasoup.types.Worker;
beforeEach(() => worker && !worker.closed && worker.close()); beforeEach(() => worker && !worker.closed && worker.close());
afterEach(() => worker && !worker.closed && worker.close()); afterEach(() => worker && !worker.closed && worker.close());
test('Worker.workerBin matches mediasoup-worker absolute path', async () =>
{
const workerBin = process.env.MEDIASOUP_WORKER_BIN
? process.env.MEDIASOUP_WORKER_BIN
: process.env.MEDIASOUP_BUILDTYPE === 'Debug'
? path.join(__dirname, '..', '..', '..', 'worker', 'out', 'Debug', 'mediasoup-worker')
: path.join(__dirname, '..', '..', '..', 'worker', 'out', 'Release', 'mediasoup-worker');
expect(mediasoup.workerBin).toBe(workerBin);
});
test('createWorker() succeeds', async () => test('createWorker() succeeds', async () =>
{ {
const onObserverNewWorker = jest.fn(); const onObserverNewWorker = jest.fn();
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论