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

Node: Add new worker.on('subprocessclose') to fix Node tests (#1307)

上级 82017d1d
# Changelog # Changelog
### NEXT
- Node: Add new `worker.on('subprocessclose')` event ([PR #1307](https://github.com/versatica/mediasoup/pull/1307)).
### 3.13.15 ### 3.13.15
- Add worker prebuild binary for Linux kernel 6 ([PR #1300](https://github.com/versatica/mediasoup/pull/1300)). - Add worker prebuild binary for Linux kernel 6 ([PR #1300](https://github.com/versatica/mediasoup/pull/1300)).
......
...@@ -228,15 +228,13 @@ export class Channel extends EnhancedEventEmitter { ...@@ -228,15 +228,13 @@ export class Channel extends EnhancedEventEmitter {
this.#producerSocket.removeAllListeners('error'); this.#producerSocket.removeAllListeners('error');
this.#producerSocket.on('error', () => {}); this.#producerSocket.on('error', () => {});
// Destroy the socket after a while to allow pending incoming messages. // Destroy the sockets.
setTimeout(() => {
try { try {
this.#producerSocket.destroy(); this.#producerSocket.destroy();
} catch (error) {} } catch (error) {}
try { try {
this.#consumerSocket.destroy(); this.#consumerSocket.destroy();
} catch (error) {} } catch (error) {}
}, 200);
} }
/** /**
......
...@@ -200,6 +200,7 @@ export type WorkerDump = { ...@@ -200,6 +200,7 @@ export type WorkerDump = {
export type WorkerEvents = { export type WorkerEvents = {
died: [Error]; died: [Error];
subprocessclose: [];
listenererror: [string, Error]; listenererror: [string, Error];
// Private events. // Private events.
'@success': []; '@success': [];
...@@ -244,7 +245,7 @@ export class Worker< ...@@ -244,7 +245,7 @@ export class Worker<
WorkerAppData extends AppData = AppData, WorkerAppData extends AppData = AppData,
> extends EnhancedEventEmitter<WorkerEvents> { > extends EnhancedEventEmitter<WorkerEvents> {
// mediasoup-worker child process. // mediasoup-worker child process.
#child?: ChildProcess; #child: ChildProcess;
// Worker process PID. // Worker process PID.
readonly #pid: number; readonly #pid: number;
...@@ -258,6 +259,9 @@ export class Worker< ...@@ -258,6 +259,9 @@ export class Worker<
// Died dlag. // Died dlag.
#died = false; #died = false;
// Worker subprocess closed flag.
#subprocessClosed = false;
// Custom app data. // Custom app data.
#appData: WorkerAppData; #appData: WorkerAppData;
...@@ -389,7 +393,10 @@ export class Worker< ...@@ -389,7 +393,10 @@ export class Worker<
}); });
this.#child.on('exit', (code, signal) => { this.#child.on('exit', (code, signal) => {
this.#child = undefined; // If killed by ourselves, do nothing.
if (this.#child.killed) {
return;
}
if (!spawnDone) { if (!spawnDone) {
spawnDone = true; spawnDone = true;
...@@ -431,7 +438,10 @@ export class Worker< ...@@ -431,7 +438,10 @@ export class Worker<
}); });
this.#child.on('error', error => { this.#child.on('error', error => {
this.#child = undefined; // If killed by ourselves, do nothing.
if (this.#child.killed) {
return;
}
if (!spawnDone) { if (!spawnDone) {
spawnDone = true; spawnDone = true;
...@@ -455,6 +465,19 @@ export class Worker< ...@@ -455,6 +465,19 @@ export class Worker<
} }
}); });
this.#child.on('close', (code, signal) => {
logger.debug(
'worker subprocess closed [pid:%s, code:%s, signal:%s]',
this.#pid,
code,
signal,
);
this.#subprocessClosed = true;
this.safeEmit('subprocessclose');
});
// Be ready for 3rd party worker libraries logging to stdout. // Be ready for 3rd party worker libraries logging to stdout.
this.#child.stdout!.on('data', buffer => { this.#child.stdout!.on('data', buffer => {
for (const line of buffer.toString('utf8').split('\n')) { for (const line of buffer.toString('utf8').split('\n')) {
...@@ -495,6 +518,13 @@ export class Worker< ...@@ -495,6 +518,13 @@ export class Worker<
return this.#died; return this.#died;
} }
/**
* Whether the Worker subprocess is closed.
*/
get subprocessClosed(): boolean {
return this.#subprocessClosed;
}
/** /**
* App custom data. * App custom data.
*/ */
...@@ -545,15 +575,7 @@ export class Worker< ...@@ -545,15 +575,7 @@ export class Worker<
this.#closed = true; this.#closed = true;
// Kill the worker process. // Kill the worker process.
if (this.#child) {
// Remove event listeners but leave a fake 'error' hander to avoid
// propagation.
this.#child.removeAllListeners('exit');
this.#child.removeAllListeners('error');
this.#child.on('error', () => {});
this.#child.kill('SIGTERM'); this.#child.kill('SIGTERM');
this.#child = undefined;
}
// Close the Channel instance. // Close the Channel instance.
this.#channel.close(); this.#channel.close();
......
...@@ -27,8 +27,14 @@ beforeEach(async () => { ...@@ -27,8 +27,14 @@ beforeEach(async () => {
ctx.router = await ctx.worker.createRouter({ mediaCodecs: ctx.mediaCodecs }); ctx.router = await ctx.worker.createRouter({ mediaCodecs: ctx.mediaCodecs });
}); });
afterEach(() => { afterEach(async () => {
ctx.worker?.close(); ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
}); });
test('router.createActiveSpeakerObserver() succeeds', async () => { test('router.createActiveSpeakerObserver() succeeds', async () => {
......
...@@ -27,8 +27,14 @@ beforeEach(async () => { ...@@ -27,8 +27,14 @@ beforeEach(async () => {
ctx.router = await ctx.worker.createRouter({ mediaCodecs: ctx.mediaCodecs }); ctx.router = await ctx.worker.createRouter({ mediaCodecs: ctx.mediaCodecs });
}); });
afterEach(() => { afterEach(async () => {
ctx.worker?.close(); ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
}); });
test('router.createAudioLevelObserver() succeeds', async () => { test('router.createAudioLevelObserver() succeeds', async () => {
......
...@@ -241,8 +241,14 @@ beforeEach(async () => { ...@@ -241,8 +241,14 @@ beforeEach(async () => {
); );
}); });
afterEach(() => { afterEach(async () => {
ctx.worker?.close(); ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
}); });
test('transport.consume() succeeds', async () => { test('transport.consume() succeeds', async () => {
...@@ -330,7 +336,7 @@ test('transport.consume() succeeds', async () => { ...@@ -330,7 +336,7 @@ test('transport.consume() succeeds', async () => {
).toBe(true); ).toBe(true);
// Pause videoProducer. // Pause videoProducer.
ctx.videoProducer!.pause(); await ctx.videoProducer!.pause();
const videoConsumer = await ctx.webRtcTransport2!.consume({ const videoConsumer = await ctx.webRtcTransport2!.consume({
producerId: ctx.videoProducer!.id, producerId: ctx.videoProducer!.id,
...@@ -987,22 +993,25 @@ test('Consumer emits "producerpause" and "producerresume"', async () => { ...@@ -987,22 +993,25 @@ test('Consumer emits "producerpause" and "producerresume"', async () => {
rtpCapabilities: ctx.consumerDeviceCapabilities, rtpCapabilities: ctx.consumerDeviceCapabilities,
}); });
await new Promise<void>(resolve => { // eslint-disable-next-line no-async-promise-executor
await new Promise<void>(async resolve => {
audioConsumer.on('producerpause', resolve); audioConsumer.on('producerpause', resolve);
ctx.audioProducer!.pause().catch(() => {}); // Let's await for pause() to resolve to avoid aborted channel requests
// due to worker closure.
await ctx.audioProducer!.pause();
}); });
expect(audioConsumer.paused).toBe(false); expect(audioConsumer.paused).toBe(false);
expect(audioConsumer.producerPaused).toBe(true); expect(audioConsumer.producerPaused).toBe(true);
await new Promise<void>(resolve => { // eslint-disable-next-line no-async-promise-executor
await new Promise<void>(async resolve => {
audioConsumer.on('producerresume', resolve); audioConsumer.on('producerresume', resolve);
// Let's catch rejection since the test will complete before we get the // Let's await for resume() to resolve to avoid aborted channel requests
// response to this channel request, and if we don't handle that rejection // due to worker closure.
// it will make Jest fail any other random test. await ctx.audioProducer!.resume();
ctx.audioProducer!.resume().catch(() => {});
}); });
expect(audioConsumer.paused).toBe(false); expect(audioConsumer.paused).toBe(false);
......
...@@ -40,8 +40,14 @@ beforeEach(async () => { ...@@ -40,8 +40,14 @@ beforeEach(async () => {
); );
}); });
afterEach(() => { afterEach(async () => {
ctx.worker?.close(); ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
}); });
test('transport.consumeData() succeeds', async () => { test('transport.consumeData() succeeds', async () => {
......
...@@ -44,8 +44,14 @@ beforeEach(async () => { ...@@ -44,8 +44,14 @@ beforeEach(async () => {
}); });
}); });
afterEach(() => { afterEach(async () => {
ctx.worker?.close(); ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
}); });
test('webRtcTransport1.produceData() succeeds', async () => { test('webRtcTransport1.produceData() succeeds', async () => {
......
...@@ -12,8 +12,14 @@ beforeEach(async () => { ...@@ -12,8 +12,14 @@ beforeEach(async () => {
ctx.router = await ctx.worker.createRouter(); ctx.router = await ctx.worker.createRouter();
}); });
afterEach(() => { afterEach(async () => {
ctx.worker?.close(); ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
}); });
test('router.createDirectTransport() succeeds', async () => { test('router.createDirectTransport() succeeds', async () => {
...@@ -138,7 +144,7 @@ test('dataProducer.send() succeeds', async () => { ...@@ -138,7 +144,7 @@ test('dataProducer.send() succeeds', async () => {
); );
}); });
sendNextMessage(); await sendNextMessage();
async function sendNextMessage(): Promise<void> { async function sendNextMessage(): Promise<void> {
const id = ++numSentMessages; const id = ++numSentMessages;
......
...@@ -195,9 +195,21 @@ beforeEach(async () => { ...@@ -195,9 +195,21 @@ beforeEach(async () => {
); );
}); });
afterEach(() => { afterEach(async () => {
ctx.worker1?.close(); ctx.worker1?.close();
ctx.worker2?.close(); ctx.worker2?.close();
if (ctx.worker1?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker1?.on('subprocessclose', resolve),
);
}
if (ctx.worker2?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker2?.on('subprocessclose', resolve),
);
}
}); });
test('router.pipeToRouter() succeeds with audio', async () => { test('router.pipeToRouter() succeeds with audio', async () => {
......
...@@ -49,8 +49,14 @@ beforeEach(async () => { ...@@ -49,8 +49,14 @@ beforeEach(async () => {
ctx.router = await ctx.worker.createRouter({ mediaCodecs: ctx.mediaCodecs }); ctx.router = await ctx.worker.createRouter({ mediaCodecs: ctx.mediaCodecs });
}); });
afterEach(() => { afterEach(async () => {
ctx.worker?.close(); ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
}); });
test('router.createPlainTransport() succeeds', async () => { test('router.createPlainTransport() succeeds', async () => {
......
...@@ -144,8 +144,14 @@ beforeEach(async () => { ...@@ -144,8 +144,14 @@ beforeEach(async () => {
}); });
}); });
afterEach(() => { afterEach(async () => {
ctx.worker?.close(); ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
}); });
test('webRtcTransport1.produce() succeeds', async () => { test('webRtcTransport1.produce() succeeds', async () => {
......
...@@ -42,8 +42,14 @@ beforeEach(async () => { ...@@ -42,8 +42,14 @@ beforeEach(async () => {
ctx.worker = await mediasoup.createWorker(); ctx.worker = await mediasoup.createWorker();
}); });
afterEach(() => { afterEach(async () => {
ctx.worker?.close(); ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
}); });
test('worker.createRouter() succeeds', async () => { test('worker.createRouter() succeeds', async () => {
......
...@@ -13,8 +13,14 @@ beforeEach(async () => { ...@@ -13,8 +13,14 @@ beforeEach(async () => {
ctx.worker = await mediasoup.createWorker(); ctx.worker = await mediasoup.createWorker();
}); });
afterEach(() => { afterEach(async () => {
ctx.worker?.close(); ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
}); });
test('worker.createWebRtcServer() succeeds', async () => { test('worker.createWebRtcServer() succeeds', async () => {
......
...@@ -54,8 +54,14 @@ beforeEach(async () => { ...@@ -54,8 +54,14 @@ beforeEach(async () => {
ctx.router = await ctx.worker.createRouter({ mediaCodecs: ctx.mediaCodecs }); ctx.router = await ctx.worker.createRouter({ mediaCodecs: ctx.mediaCodecs });
}); });
afterEach(() => { afterEach(async () => {
ctx.worker?.close(); ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
}); });
test('router.createWebRtcTransport() succeeds', async () => { test('router.createWebRtcTransport() succeeds', async () => {
......
...@@ -48,6 +48,8 @@ test('createWorker() succeeds', async () => { ...@@ -48,6 +48,8 @@ test('createWorker() succeeds', async () => {
worker1.close(); worker1.close();
await new Promise<void>(resolve => worker1.on('subprocessclose', resolve));
expect(worker1.closed).toBe(true); expect(worker1.closed).toBe(true);
expect(worker1.died).toBe(false); expect(worker1.died).toBe(false);
...@@ -70,6 +72,8 @@ test('createWorker() succeeds', async () => { ...@@ -70,6 +72,8 @@ test('createWorker() succeeds', async () => {
worker2.close(); worker2.close();
await new Promise<void>(resolve => worker2.on('subprocessclose', resolve));
expect(worker2.closed).toBe(true); expect(worker2.closed).toBe(true);
expect(worker2.died).toBe(false); expect(worker2.died).toBe(false);
}, 2000); }, 2000);
...@@ -111,6 +115,8 @@ test('worker.updateSettings() succeeds', async () => { ...@@ -111,6 +115,8 @@ test('worker.updateSettings() succeeds', async () => {
).resolves.toBeUndefined(); ).resolves.toBeUndefined();
worker.close(); worker.close();
await new Promise<void>(resolve => worker.on('subprocessclose', resolve));
}, 2000); }, 2000);
test('worker.updateSettings() with wrong settings rejects with TypeError', async () => { test('worker.updateSettings() with wrong settings rejects with TypeError', async () => {
...@@ -122,6 +128,8 @@ test('worker.updateSettings() with wrong settings rejects with TypeError', async ...@@ -122,6 +128,8 @@ test('worker.updateSettings() with wrong settings rejects with TypeError', async
); );
worker.close(); worker.close();
await new Promise<void>(resolve => worker.on('subprocessclose', resolve));
}, 2000); }, 2000);
test('worker.updateSettings() rejects with InvalidStateError if closed', async () => { test('worker.updateSettings() rejects with InvalidStateError if closed', async () => {
...@@ -129,6 +137,8 @@ test('worker.updateSettings() rejects with InvalidStateError if closed', async ( ...@@ -129,6 +137,8 @@ test('worker.updateSettings() rejects with InvalidStateError if closed', async (
worker.close(); worker.close();
await new Promise<void>(resolve => worker.on('subprocessclose', resolve));
await expect(worker.updateSettings({ logLevel: 'error' })).rejects.toThrow( await expect(worker.updateSettings({ logLevel: 'error' })).rejects.toThrow(
InvalidStateError, InvalidStateError,
); );
...@@ -155,6 +165,8 @@ test('worker.dump() rejects with InvalidStateError if closed', async () => { ...@@ -155,6 +165,8 @@ test('worker.dump() rejects with InvalidStateError if closed', async () => {
worker.close(); worker.close();
await new Promise<void>(resolve => worker.on('subprocessclose', resolve));
await expect(worker.dump()).rejects.toThrow(InvalidStateError); await expect(worker.dump()).rejects.toThrow(InvalidStateError);
}, 2000); }, 2000);
...@@ -164,6 +176,8 @@ test('worker.getResourceUsage() succeeds', async () => { ...@@ -164,6 +176,8 @@ test('worker.getResourceUsage() succeeds', async () => {
await expect(worker.getResourceUsage()).resolves.toMatchObject({}); await expect(worker.getResourceUsage()).resolves.toMatchObject({});
worker.close(); worker.close();
await new Promise<void>(resolve => worker.on('subprocessclose', resolve));
}, 2000); }, 2000);
test('worker.close() succeeds', async () => { test('worker.close() succeeds', async () => {
...@@ -173,6 +187,8 @@ test('worker.close() succeeds', async () => { ...@@ -173,6 +187,8 @@ test('worker.close() succeeds', async () => {
worker.observer.once('close', onObserverClose); worker.observer.once('close', onObserverClose);
worker.close(); worker.close();
await new Promise<void>(resolve => worker.on('subprocessclose', resolve));
expect(onObserverClose).toHaveBeenCalledTimes(1); expect(onObserverClose).toHaveBeenCalledTimes(1);
expect(worker.closed).toBe(true); expect(worker.closed).toBe(true);
expect(worker.died).toBe(false); expect(worker.died).toBe(false);
...@@ -209,6 +225,10 @@ test('Worker emits "died" if worker process died unexpectedly', async () => { ...@@ -209,6 +225,10 @@ test('Worker emits "died" if worker process died unexpectedly', async () => {
process.kill(worker1.pid, 'SIGINT'); process.kill(worker1.pid, 'SIGINT');
}); });
if (!worker1.subprocessClosed) {
await new Promise<void>(resolve => worker1.on('subprocessclose', resolve));
}
expect(onDied).toHaveBeenCalledTimes(1); expect(onDied).toHaveBeenCalledTimes(1);
expect(onObserverClose).toHaveBeenCalledTimes(1); expect(onObserverClose).toHaveBeenCalledTimes(1);
expect(worker1.closed).toBe(true); expect(worker1.closed).toBe(true);
...@@ -241,6 +261,10 @@ test('Worker emits "died" if worker process died unexpectedly', async () => { ...@@ -241,6 +261,10 @@ test('Worker emits "died" if worker process died unexpectedly', async () => {
process.kill(worker2.pid, 'SIGTERM'); process.kill(worker2.pid, 'SIGTERM');
}); });
if (!worker2.subprocessClosed) {
await new Promise<void>(resolve => worker2.on('subprocessclose', resolve));
}
expect(onDied).toHaveBeenCalledTimes(1); expect(onDied).toHaveBeenCalledTimes(1);
expect(onObserverClose).toHaveBeenCalledTimes(1); expect(onObserverClose).toHaveBeenCalledTimes(1);
expect(worker2.closed).toBe(true); expect(worker2.closed).toBe(true);
...@@ -273,6 +297,10 @@ test('Worker emits "died" if worker process died unexpectedly', async () => { ...@@ -273,6 +297,10 @@ test('Worker emits "died" if worker process died unexpectedly', async () => {
process.kill(worker3.pid, 'SIGKILL'); process.kill(worker3.pid, 'SIGKILL');
}); });
if (!worker3.subprocessClosed) {
await new Promise<void>(resolve => worker3.on('subprocessclose', resolve));
}
expect(onDied).toHaveBeenCalledTimes(1); expect(onDied).toHaveBeenCalledTimes(1);
expect(onObserverClose).toHaveBeenCalledTimes(1); expect(onObserverClose).toHaveBeenCalledTimes(1);
expect(worker3.closed).toBe(true); expect(worker3.closed).toBe(true);
...@@ -298,7 +326,7 @@ if (os.platform() !== 'win32') { ...@@ -298,7 +326,7 @@ if (os.platform() !== 'win32') {
expect(worker.closed).toBe(false); expect(worker.closed).toBe(false);
worker.close(); worker.close();
resolve(); worker.on('subprocessclose', resolve);
}, 2000); }, 2000);
}); });
}, 3000); }, 3000);
......
...@@ -103,8 +103,14 @@ beforeEach(async () => { ...@@ -103,8 +103,14 @@ beforeEach(async () => {
}); });
}); });
afterEach(() => { afterEach(async () => {
ctx.worker?.close(); ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
}); });
test('produce() and consume() succeed', async () => { test('produce() and consume() succeed', async () => {
......
...@@ -99,10 +99,16 @@ afterEach(async () => { ...@@ -99,10 +99,16 @@ afterEach(async () => {
ctx.sctpSocket?.end(); ctx.sctpSocket?.end();
ctx.worker?.close(); ctx.worker?.close();
if (ctx.worker?.subprocessClosed === false) {
await new Promise<void>(
resolve => ctx.worker?.on('subprocessclose', resolve),
);
}
// NOTE: For some reason we have to wait a bit for the SCTP stuff to release // NOTE: For some reason we have to wait a bit for the SCTP stuff to release
// internal things, otherwise Jest reports open handles. We don't care much // internal things, otherwise Jest reports open handles. We don't care much
// honestly. // honestly.
await new Promise(resolve => setTimeout(resolve, 2000)); await new Promise(resolve => setTimeout(resolve, 1000));
}); });
test('ordered DataProducer delivers all SCTP messages to the DataConsumer', async () => { test('ordered DataProducer delivers all SCTP messages to the DataConsumer', async () => {
......
...@@ -296,7 +296,7 @@ function installInvoke() { ...@@ -296,7 +296,7 @@ function installInvoke() {
// Install pip invoke into custom location, so we don't depend on system-wide // Install pip invoke into custom location, so we don't depend on system-wide
// installation. // installation.
executeCmd( executeCmd(
`"${PYTHON}" -m pip install --upgrade --no-user --target="${PIP_INVOKE_DIR}" invoke`, `"${PYTHON}" -m pip install --upgrade --no-user --target "${PIP_INVOKE_DIR}" invoke`,
/* exitOnError */ true, /* exitOnError */ true,
); );
} }
...@@ -420,7 +420,7 @@ function flatcWorker() { ...@@ -420,7 +420,7 @@ function flatcWorker() {
function testNode() { function testNode() {
logInfo('testNode()'); logInfo('testNode()');
executeCmd(`jest --detectOpenHandles ${args}`); executeCmd(`jest --silent false --detectOpenHandles ${args}`);
} }
function testWorker() { function testWorker() {
......
...@@ -47,75 +47,75 @@ invoke: ...@@ -47,75 +47,75 @@ invoke:
ifeq ($(wildcard $(PIP_INVOKE_DIR)),) ifeq ($(wildcard $(PIP_INVOKE_DIR)),)
# Install pip invoke into custom location, so we don't depend on system-wide # Install pip invoke into custom location, so we don't depend on system-wide
# installation. # installation.
$(PYTHON) -m pip install --upgrade --no-user --target="$(PIP_INVOKE_DIR)" invoke "$(PYTHON)" -m pip install --upgrade --no-user --target "$(PIP_INVOKE_DIR)" invoke
endif endif
meson-ninja: invoke meson-ninja: invoke
$(PYTHON) -m invoke meson-ninja "$(PYTHON)" -m invoke meson-ninja
setup: invoke setup: invoke
$(PYTHON) -m invoke setup "$(PYTHON)" -m invoke setup
clean: invoke clean: invoke
$(PYTHON) -m invoke clean "$(PYTHON)" -m invoke clean
clean-build: invoke clean-build: invoke
$(PYTHON) -m invoke clean-build "$(PYTHON)" -m invoke clean-build
clean-pip: invoke clean-pip: invoke
$(PYTHON) -m invoke clean-pip "$(PYTHON)" -m invoke clean-pip
clean-subprojects: invoke clean-subprojects: invoke
$(PYTHON) -m invoke clean-subprojects "$(PYTHON)" -m invoke clean-subprojects
clean-all: invoke clean-all: invoke
$(PYTHON) -m invoke clean-all "$(PYTHON)" -m invoke clean-all
# It requires the SUBPROJECT environment variable. # It requires the SUBPROJECT environment variable.
update-wrap-file: invoke update-wrap-file: invoke
$(PYTHON) -m invoke subprojects $(SUBPROJECT) "$(PYTHON)" -m invoke subprojects $(SUBPROJECT)
mediasoup-worker: invoke mediasoup-worker: invoke
$(PYTHON) -m invoke mediasoup-worker "$(PYTHON)" -m invoke mediasoup-worker
libmediasoup-worker: invoke libmediasoup-worker: invoke
$(PYTHON) -m invoke libmediasoup-worker "$(PYTHON)" -m invoke libmediasoup-worker
flatc: invoke flatc: invoke
$(PYTHON) -m invoke flatc "$(PYTHON)" -m invoke flatc
xcode: invoke xcode: invoke
$(PYTHON) -m invoke xcode "$(PYTHON)" -m invoke xcode
lint: invoke lint: invoke
$(PYTHON) -m invoke lint "$(PYTHON)" -m invoke lint
format: invoke format: invoke
$(PYTHON) -m invoke format "$(PYTHON)" -m invoke format
test: invoke test: invoke
$(PYTHON) -m invoke test "$(PYTHON)" -m invoke test
test-asan: invoke test-asan: invoke
$(PYTHON) -m invoke test-asan "$(PYTHON)" -m invoke test-asan
tidy: invoke tidy: invoke
$(PYTHON) -m invoke tidy "$(PYTHON)" -m invoke tidy
fuzzer: invoke fuzzer: invoke
$(PYTHON) -m invoke fuzzer "$(PYTHON)" -m invoke fuzzer
fuzzer-run-all: invoke fuzzer-run-all: invoke
$(PYTHON) -m invoke fuzzer-run-all "$(PYTHON)" -m invoke fuzzer-run-all
docker: invoke docker: invoke
$(PYTHON) -m invoke docker "$(PYTHON)" -m invoke docker
docker-run: invoke docker-run: invoke
$(PYTHON) -m invoke docker-run "$(PYTHON)" -m invoke docker-run
docker-alpine: invoke docker-alpine: invoke
$(PYTHON) -m invoke docker-alpine "$(PYTHON)" -m invoke docker-alpine
docker-alpine-run: invoke docker-alpine-run: invoke
$(PYTHON) -m invoke docker-alpine-run "$(PYTHON)" -m invoke docker-alpine-run
...@@ -107,14 +107,14 @@ def meson_ninja(ctx): ...@@ -107,14 +107,14 @@ def meson_ninja(ctx):
# fallback to command without `--system` if the first one fails. # fallback to command without `--system` if the first one fails.
try: try:
ctx.run( ctx.run(
f'"{PYTHON}" -m pip install --system --upgrade --no-user --target="{PIP_MESON_NINJA_DIR}" pip setuptools', f'"{PYTHON}" -m pip install --system --upgrade --no-user --target "{PIP_MESON_NINJA_DIR}" pip setuptools',
echo=True, echo=True,
hide=True, hide=True,
shell=SHELL shell=SHELL
); );
except: except:
ctx.run( ctx.run(
f'"{PYTHON}" -m pip install --upgrade --no-user --target="{PIP_MESON_NINJA_DIR}" pip setuptools', f'"{PYTHON}" -m pip install --upgrade --no-user --target "{PIP_MESON_NINJA_DIR}" pip setuptools',
echo=True, echo=True,
pty=PTY_SUPPORTED, pty=PTY_SUPPORTED,
shell=SHELL shell=SHELL
...@@ -127,7 +127,7 @@ def meson_ninja(ctx): ...@@ -127,7 +127,7 @@ def meson_ninja(ctx):
# Install meson and ninja using pip into our custom location, so we don't # Install meson and ninja using pip into our custom location, so we don't
# depend on system-wide installation. # depend on system-wide installation.
ctx.run( ctx.run(
f'"{PYTHON}" -m pip install --upgrade --no-user --target="{PIP_MESON_NINJA_DIR}" {pip_build_binaries} meson=={MESON_VERSION} ninja=={NINJA_VERSION}', f'"{PYTHON}" -m pip install --upgrade --no-user --target "{PIP_MESON_NINJA_DIR}" {pip_build_binaries} meson=={MESON_VERSION} ninja=={NINJA_VERSION}',
echo=True, echo=True,
pty=PTY_SUPPORTED, pty=PTY_SUPPORTED,
shell=SHELL shell=SHELL
...@@ -140,7 +140,7 @@ def setup(ctx): ...@@ -140,7 +140,7 @@ def setup(ctx):
Run meson setup Run meson setup
""" """
if MEDIASOUP_BUILDTYPE == 'Release': if MEDIASOUP_BUILDTYPE == 'Release':
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype release -Db_ndebug=true {MESON_ARGS} "{BUILD_DIR}"', f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype release -Db_ndebug=true {MESON_ARGS} "{BUILD_DIR}"',
echo=True, echo=True,
...@@ -148,7 +148,7 @@ def setup(ctx): ...@@ -148,7 +148,7 @@ def setup(ctx):
shell=SHELL shell=SHELL
); );
elif MEDIASOUP_BUILDTYPE == 'Debug': elif MEDIASOUP_BUILDTYPE == 'Debug':
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype debug {MESON_ARGS} "{BUILD_DIR}"', f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype debug {MESON_ARGS} "{BUILD_DIR}"',
echo=True, echo=True,
...@@ -156,7 +156,7 @@ def setup(ctx): ...@@ -156,7 +156,7 @@ def setup(ctx):
shell=SHELL shell=SHELL
); );
else: else:
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype {MEDIASOUP_BUILDTYPE} -Db_ndebug=if-release {MESON_ARGS} "{BUILD_DIR}"', f'"{MESON}" setup --prefix "{MEDIASOUP_INSTALL_DIR}" --bindir "" --libdir "" --buildtype {MEDIASOUP_BUILDTYPE} -Db_ndebug=if-release {MESON_ARGS} "{BUILD_DIR}"',
echo=True, echo=True,
...@@ -208,7 +208,7 @@ def clean_subprojects(ctx): ...@@ -208,7 +208,7 @@ def clean_subprojects(ctx):
""" """
Clean meson subprojects Clean meson subprojects
""" """
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" subprojects purge --include-cache --confirm', f'"{MESON}" subprojects purge --include-cache --confirm',
echo=True, echo=True,
...@@ -222,7 +222,7 @@ def clean_all(ctx): ...@@ -222,7 +222,7 @@ def clean_all(ctx):
""" """
Clean meson subprojects and all installed/built artificats Clean meson subprojects and all installed/built artificats
""" """
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
try: try:
ctx.run( ctx.run(
f'"{MESON}" subprojects purge --include-cache --confirm', f'"{MESON}" subprojects purge --include-cache --confirm',
...@@ -244,7 +244,7 @@ def update_wrap_file(ctx, subproject): ...@@ -244,7 +244,7 @@ def update_wrap_file(ctx, subproject):
""" """
Update the wrap file of a subproject Update the wrap file of a subproject
""" """
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" subprojects update --reset {subproject}', f'"{MESON}" subprojects update --reset {subproject}',
echo=True, echo=True,
...@@ -258,7 +258,7 @@ def flatc(ctx): ...@@ -258,7 +258,7 @@ def flatc(ctx):
""" """
Compile FlatBuffers FBS files Compile FlatBuffers FBS files
""" """
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" compile -C "{BUILD_DIR}" flatbuffers-generator', f'"{MESON}" compile -C "{BUILD_DIR}" flatbuffers-generator',
echo=True, echo=True,
...@@ -276,14 +276,14 @@ def mediasoup_worker(ctx): ...@@ -276,14 +276,14 @@ def mediasoup_worker(ctx):
print('skipping mediasoup-worker compilation due to the existence of the MEDIASOUP_WORKER_BIN environment variable'); print('skipping mediasoup-worker compilation due to the existence of the MEDIASOUP_WORKER_BIN environment variable');
return; return;
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker', f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker',
echo=True, echo=True,
pty=PTY_SUPPORTED, pty=PTY_SUPPORTED,
shell=SHELL shell=SHELL
); );
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker', f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker',
echo=True, echo=True,
...@@ -297,14 +297,14 @@ def libmediasoup_worker(ctx): ...@@ -297,14 +297,14 @@ def libmediasoup_worker(ctx):
""" """
Compile libmediasoup-worker library Compile libmediasoup-worker library
""" """
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} libmediasoup-worker', f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} libmediasoup-worker',
echo=True, echo=True,
pty=PTY_SUPPORTED, pty=PTY_SUPPORTED,
shell=SHELL shell=SHELL
); );
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags libmediasoup-worker', f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags libmediasoup-worker',
echo=True, echo=True,
...@@ -318,7 +318,7 @@ def xcode(ctx): ...@@ -318,7 +318,7 @@ def xcode(ctx):
""" """
Setup Xcode project Setup Xcode project
""" """
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" setup --buildtype {MEDIASOUP_BUILDTYPE.lower()} --backend xcode "{MEDIASOUP_OUT_DIR}/xcode"', f'"{MESON}" setup --buildtype {MEDIASOUP_BUILDTYPE.lower()} --backend xcode "{MEDIASOUP_OUT_DIR}/xcode"',
echo=True, echo=True,
...@@ -332,7 +332,7 @@ def lint(ctx): ...@@ -332,7 +332,7 @@ def lint(ctx):
""" """
Lint source code Lint source code
""" """
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{NPM}" run lint --prefix scripts/', f'"{NPM}" run lint --prefix scripts/',
echo=True, echo=True,
...@@ -349,7 +349,7 @@ def lint(ctx): ...@@ -349,7 +349,7 @@ def lint(ctx):
shell=SHELL shell=SHELL
); );
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{PYTHON}" -m pylint tasks.py', f'"{PYTHON}" -m pylint tasks.py',
echo=True, echo=True,
...@@ -363,7 +363,7 @@ def format(ctx): ...@@ -363,7 +363,7 @@ def format(ctx):
""" """
Format source code according to lint rules Format source code according to lint rules
""" """
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{NPM}" run format --prefix scripts/', f'"{NPM}" run format --prefix scripts/',
echo=True, echo=True,
...@@ -377,14 +377,14 @@ def test(ctx): ...@@ -377,14 +377,14 @@ def test(ctx):
""" """
Run worker tests Run worker tests
""" """
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test', f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test',
echo=True, echo=True,
pty=PTY_SUPPORTED, pty=PTY_SUPPORTED,
shell=SHELL shell=SHELL
); );
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test', f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test',
echo=True, echo=True,
...@@ -395,7 +395,7 @@ def test(ctx): ...@@ -395,7 +395,7 @@ def test(ctx):
mediasoup_worker_test = 'mediasoup-worker-test.exe' if os.name == 'nt' else 'mediasoup-worker-test'; mediasoup_worker_test = 'mediasoup-worker-test.exe' if os.name == 'nt' else 'mediasoup-worker-test';
mediasoup_test_tags = os.getenv('MEDIASOUP_TEST_TAGS') or ''; mediasoup_test_tags = os.getenv('MEDIASOUP_TEST_TAGS') or '';
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{BUILD_DIR}/{mediasoup_worker_test}" --invisibles --colour-mode=ansi {mediasoup_test_tags}', f'"{BUILD_DIR}/{mediasoup_worker_test}" --invisibles --colour-mode=ansi {mediasoup_test_tags}',
echo=True, echo=True,
...@@ -409,14 +409,14 @@ def test_asan(ctx): ...@@ -409,14 +409,14 @@ def test_asan(ctx):
""" """
Run worker test with Address Sanitizer Run worker test with Address Sanitizer
""" """
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test-asan', f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-test-asan',
echo=True, echo=True,
pty=PTY_SUPPORTED, pty=PTY_SUPPORTED,
shell=SHELL shell=SHELL
); );
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test-asan', f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-test-asan',
echo=True, echo=True,
...@@ -426,7 +426,7 @@ def test_asan(ctx): ...@@ -426,7 +426,7 @@ def test_asan(ctx):
mediasoup_test_tags = os.getenv('MEDIASOUP_TEST_TAGS') or ''; mediasoup_test_tags = os.getenv('MEDIASOUP_TEST_TAGS') or '';
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'ASAN_OPTIONS=detect_leaks=1 "{BUILD_DIR}/mediasoup-worker-test-asan" --invisibles --use-colour=yes {mediasoup_test_tags}', f'ASAN_OPTIONS=detect_leaks=1 "{BUILD_DIR}/mediasoup-worker-test-asan" --invisibles --use-colour=yes {mediasoup_test_tags}',
echo=True, echo=True,
...@@ -442,7 +442,7 @@ def tidy(ctx): ...@@ -442,7 +442,7 @@ def tidy(ctx):
""" """
mediasoup_tidy_checks = os.getenv('MEDIASOUP_TIDY_CHECKS') or ''; mediasoup_tidy_checks = os.getenv('MEDIASOUP_TIDY_CHECKS') or '';
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{PYTHON}" ./scripts/clang-tidy.py -clang-tidy-binary=./scripts/node_modules/.bin/clang-tidy -clang-apply-replacements-binary=./scripts/node_modules/.bin/clang-apply-replacements -header-filter="(Channel/**/*.hpp|DepLibSRTP.hpp|DepLibUV.hpp|DepLibWebRTC.hpp|DepOpenSSL.hpp|DepUsrSCTP.hpp|LogLevel.hpp|Logger.hpp|MediaSoupError.hpp|RTC/**/*.hpp|Settings.hpp|Utils.hpp|Worker.hpp|common.hpp|handles/**/*.hpp)" -p="{BUILD_DIR}" -j={NUM_CORES} -checks={mediasoup_tidy_checks} -quiet', f'"{PYTHON}" ./scripts/clang-tidy.py -clang-tidy-binary=./scripts/node_modules/.bin/clang-tidy -clang-apply-replacements-binary=./scripts/node_modules/.bin/clang-apply-replacements -header-filter="(Channel/**/*.hpp|DepLibSRTP.hpp|DepLibUV.hpp|DepLibWebRTC.hpp|DepOpenSSL.hpp|DepUsrSCTP.hpp|LogLevel.hpp|Logger.hpp|MediaSoupError.hpp|RTC/**/*.hpp|Settings.hpp|Utils.hpp|Worker.hpp|common.hpp|handles/**/*.hpp)" -p="{BUILD_DIR}" -j={NUM_CORES} -checks={mediasoup_tidy_checks} -quiet',
echo=True, echo=True,
...@@ -456,14 +456,14 @@ def fuzzer(ctx): ...@@ -456,14 +456,14 @@ def fuzzer(ctx):
""" """
Build the mediasoup-worker-fuzzer binary (which uses libFuzzer) Build the mediasoup-worker-fuzzer binary (which uses libFuzzer)
""" """
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-fuzzer', f'"{MESON}" compile -C "{BUILD_DIR}" -j {NUM_CORES} mediasoup-worker-fuzzer',
echo=True, echo=True,
pty=PTY_SUPPORTED, pty=PTY_SUPPORTED,
shell=SHELL shell=SHELL
); );
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-fuzzer', f'"{MESON}" install -C "{BUILD_DIR}" --no-rebuild --tags mediasoup-worker-fuzzer',
echo=True, echo=True,
...@@ -477,7 +477,7 @@ def fuzzer_run_all(ctx): ...@@ -477,7 +477,7 @@ def fuzzer_run_all(ctx):
""" """
Run all fuzzer cases Run all fuzzer cases
""" """
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'LSAN_OPTIONS=verbosity=1:log_threads=1 "{BUILD_DIR}/mediasoup-worker-fuzzer" -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus', f'LSAN_OPTIONS=verbosity=1:log_threads=1 "{BUILD_DIR}/mediasoup-worker-fuzzer" -artifact_prefix=fuzzer/reports/ -max_len=1400 fuzzer/new-corpus deps/webrtc-fuzzer-corpora/corpora/stun-corpus deps/webrtc-fuzzer-corpora/corpora/rtp-corpus deps/webrtc-fuzzer-corpora/corpora/rtcp-corpus',
echo=True, echo=True,
...@@ -492,7 +492,7 @@ def docker(ctx): ...@@ -492,7 +492,7 @@ def docker(ctx):
Build a Linux Ubuntu Docker image with fuzzer capable clang++ Build a Linux Ubuntu Docker image with fuzzer capable clang++
""" """
if os.getenv('DOCKER_NO_CACHE') == 'true': if os.getenv('DOCKER_NO_CACHE') == 'true':
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{DOCKER}" build -f Dockerfile --no-cache --tag mediasoup/docker:latest .', f'"{DOCKER}" build -f Dockerfile --no-cache --tag mediasoup/docker:latest .',
echo=True, echo=True,
...@@ -500,7 +500,7 @@ def docker(ctx): ...@@ -500,7 +500,7 @@ def docker(ctx):
shell=SHELL shell=SHELL
); );
else: else:
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{DOCKER}" build -f Dockerfile --tag mediasoup/docker:latest .', f'"{DOCKER}" build -f Dockerfile --tag mediasoup/docker:latest .',
echo=True, echo=True,
...@@ -514,7 +514,7 @@ def docker_run(ctx): ...@@ -514,7 +514,7 @@ def docker_run(ctx):
""" """
Run a container of the Ubuntu Docker image created in the docker task Run a container of the Ubuntu Docker image created in the docker task
""" """
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{DOCKER}" run --name=mediasoupDocker -it --rm --privileged --cap-add SYS_PTRACE -v "{WORKER_DIR}/../:/mediasoup" mediasoup/docker:latest', f'"{DOCKER}" run --name=mediasoupDocker -it --rm --privileged --cap-add SYS_PTRACE -v "{WORKER_DIR}/../:/mediasoup" mediasoup/docker:latest',
echo=True, echo=True,
...@@ -529,7 +529,7 @@ def docker_alpine(ctx): ...@@ -529,7 +529,7 @@ def docker_alpine(ctx):
Build a Linux Alpine Docker image Build a Linux Alpine Docker image
""" """
if os.getenv('DOCKER_NO_CACHE') == 'true': if os.getenv('DOCKER_NO_CACHE') == 'true':
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{DOCKER}" build -f Dockerfile.alpine --no-cache --tag mediasoup/docker-alpine:latest .', f'"{DOCKER}" build -f Dockerfile.alpine --no-cache --tag mediasoup/docker-alpine:latest .',
echo=True, echo=True,
...@@ -537,7 +537,7 @@ def docker_alpine(ctx): ...@@ -537,7 +537,7 @@ def docker_alpine(ctx):
shell=SHELL shell=SHELL
); );
else: else:
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{DOCKER}" build -f Dockerfile.alpine --tag mediasoup/docker-alpine:latest .', f'"{DOCKER}" build -f Dockerfile.alpine --tag mediasoup/docker-alpine:latest .',
echo=True, echo=True,
...@@ -551,7 +551,7 @@ def docker_alpine_run(ctx): ...@@ -551,7 +551,7 @@ def docker_alpine_run(ctx):
""" """
Run a container of the Alpine Docker image created in the docker_alpine task Run a container of the Alpine Docker image created in the docker_alpine task
""" """
with ctx.cd(WORKER_DIR): with ctx.cd(f'"{WORKER_DIR}"'):
ctx.run( ctx.run(
f'"{DOCKER}" run --name=mediasoupDockerAlpine -it --rm --privileged --cap-add SYS_PTRACE -v "{WORKER_DIR}/../:/mediasoup" mediasoup/docker-alpine:latest', f'"{DOCKER}" run --name=mediasoupDockerAlpine -it --rm --privileged --cap-add SYS_PTRACE -v "{WORKER_DIR}/../:/mediasoup" mediasoup/docker-alpine:latest',
echo=True, echo=True,
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论