diff options
-rw-r--r-- | packages/peertube-runner/peertube-runner.ts | 1 | ||||
-rw-r--r-- | packages/peertube-runner/register/register.ts | 1 | ||||
-rw-r--r-- | packages/peertube-runner/server/server.ts | 15 | ||||
-rw-r--r-- | packages/peertube-runner/shared/ipc/ipc-client.ts | 1 | ||||
-rw-r--r-- | packages/peertube-runner/shared/ipc/ipc-server.ts | 2 | ||||
-rw-r--r-- | packages/peertube-runner/shared/ipc/shared/ipc-request.model.ts | 2 | ||||
-rw-r--r-- | server/tests/peertube-runner/client-cli.ts | 2 | ||||
-rw-r--r-- | server/tests/peertube-runner/live-transcoding.ts | 2 | ||||
-rw-r--r-- | server/tests/peertube-runner/studio-transcoding.ts | 2 | ||||
-rw-r--r-- | server/tests/peertube-runner/vod-transcoding.ts | 2 | ||||
-rw-r--r-- | server/tests/shared/peertube-runner-process.ts | 8 | ||||
-rw-r--r-- | support/doc/tools.md | 2 |
12 files changed, 24 insertions, 16 deletions
diff --git a/packages/peertube-runner/peertube-runner.ts b/packages/peertube-runner/peertube-runner.ts index 858d85e6a..32586c4d9 100644 --- a/packages/peertube-runner/peertube-runner.ts +++ b/packages/peertube-runner/peertube-runner.ts | |||
@@ -55,6 +55,7 @@ program.command('register') | |||
55 | program.command('unregister') | 55 | program.command('unregister') |
56 | .description('Unregister the runner from PeerTube instance') | 56 | .description('Unregister the runner from PeerTube instance') |
57 | .requiredOption('--url <url>', 'PeerTube instance URL', parseUrl) | 57 | .requiredOption('--url <url>', 'PeerTube instance URL', parseUrl) |
58 | .requiredOption('--runner-name <name>', 'Runner name') | ||
58 | .action(async options => { | 59 | .action(async options => { |
59 | try { | 60 | try { |
60 | await unregisterRunner(options) | 61 | await unregisterRunner(options) |
diff --git a/packages/peertube-runner/register/register.ts b/packages/peertube-runner/register/register.ts index a69390933..ca1bf0f5a 100644 --- a/packages/peertube-runner/register/register.ts +++ b/packages/peertube-runner/register/register.ts | |||
@@ -16,6 +16,7 @@ export async function registerRunner (options: { | |||
16 | 16 | ||
17 | export async function unregisterRunner (options: { | 17 | export async function unregisterRunner (options: { |
18 | url: string | 18 | url: string |
19 | runnerName: string | ||
19 | }) { | 20 | }) { |
20 | const client = new IPCClient() | 21 | const client = new IPCClient() |
21 | await client.run() | 22 | await client.run() |
diff --git a/packages/peertube-runner/server/server.ts b/packages/peertube-runner/server/server.ts index 087405dfe..e76131c74 100644 --- a/packages/peertube-runner/server/server.ts +++ b/packages/peertube-runner/server/server.ts | |||
@@ -121,27 +121,28 @@ export class RunnerServer { | |||
121 | 121 | ||
122 | async unregisterRunner (options: { | 122 | async unregisterRunner (options: { |
123 | url: string | 123 | url: string |
124 | runnerName: string | ||
124 | }) { | 125 | }) { |
125 | const { url } = options | 126 | const { url, runnerName } = options |
126 | 127 | ||
127 | const server = this.servers.find(s => s.url === url) | 128 | const server = this.servers.find(s => s.url === url && s.runnerName === runnerName) |
128 | if (!server) { | 129 | if (!server) { |
129 | logger.error(`Unknown server ${url} to unregister`) | 130 | logger.error(`Unknown server ${url} - ${runnerName} to unregister`) |
130 | return | 131 | return |
131 | } | 132 | } |
132 | 133 | ||
133 | logger.info(`Unregistering runner ${server.runnerName} on ${url}...`) | 134 | logger.info(`Unregistering runner ${runnerName} on ${url}...`) |
134 | 135 | ||
135 | try { | 136 | try { |
136 | await server.runners.unregister({ runnerToken: server.runnerToken }) | 137 | await server.runners.unregister({ runnerToken: server.runnerToken }) |
137 | } catch (err) { | 138 | } catch (err) { |
138 | logger.error({ err }, `Cannot unregister runner ${server.runnerName} on ${url}`) | 139 | logger.error({ err }, `Cannot unregister runner ${runnerName} on ${url}`) |
139 | } | 140 | } |
140 | 141 | ||
141 | this.unloadServer(server) | 142 | this.unloadServer(server) |
142 | await this.saveRegisteredInstancesInConf() | 143 | await this.saveRegisteredInstancesInConf() |
143 | 144 | ||
144 | logger.info(`Unregistered runner ${server.runnerName} on ${server.url}`) | 145 | logger.info(`Unregistered runner ${runnerName} on ${url}`) |
145 | } | 146 | } |
146 | 147 | ||
147 | private unloadServer (server: PeerTubeServer) { | 148 | private unloadServer (server: PeerTubeServer) { |
@@ -195,7 +196,7 @@ export class RunnerServer { | |||
195 | if (code === ServerErrorCode.UNKNOWN_RUNNER_TOKEN) { | 196 | if (code === ServerErrorCode.UNKNOWN_RUNNER_TOKEN) { |
196 | logger.error({ err }, `Unregistering ${server.url} as the runner token ${server.runnerToken} is invalid`) | 197 | logger.error({ err }, `Unregistering ${server.url} as the runner token ${server.runnerToken} is invalid`) |
197 | 198 | ||
198 | await this.unregisterRunner({ url: server.url }) | 199 | await this.unregisterRunner({ url: server.url, runnerName: server.runnerName }) |
199 | return | 200 | return |
200 | } | 201 | } |
201 | 202 | ||
diff --git a/packages/peertube-runner/shared/ipc/ipc-client.ts b/packages/peertube-runner/shared/ipc/ipc-client.ts index db8d7f1bf..f8e72f97f 100644 --- a/packages/peertube-runner/shared/ipc/ipc-client.ts +++ b/packages/peertube-runner/shared/ipc/ipc-client.ts | |||
@@ -47,6 +47,7 @@ export class IPCClient { | |||
47 | 47 | ||
48 | async askUnregister (options: { | 48 | async askUnregister (options: { |
49 | url: string | 49 | url: string |
50 | runnerName: string | ||
50 | }) { | 51 | }) { |
51 | const req: IPCRequest = { | 52 | const req: IPCRequest = { |
52 | type: 'unregister', | 53 | type: 'unregister', |
diff --git a/packages/peertube-runner/shared/ipc/ipc-server.ts b/packages/peertube-runner/shared/ipc/ipc-server.ts index 922dc93e5..4b67d01ae 100644 --- a/packages/peertube-runner/shared/ipc/ipc-server.ts +++ b/packages/peertube-runner/shared/ipc/ipc-server.ts | |||
@@ -40,7 +40,7 @@ export class IPCServer { | |||
40 | return undefined | 40 | return undefined |
41 | 41 | ||
42 | case 'unregister': | 42 | case 'unregister': |
43 | await this.runnerServer.unregisterRunner({ url: req.url }) | 43 | await this.runnerServer.unregisterRunner(pick(req, [ 'url', 'runnerName' ])) |
44 | return undefined | 44 | return undefined |
45 | 45 | ||
46 | case 'list-registered': | 46 | case 'list-registered': |
diff --git a/packages/peertube-runner/shared/ipc/shared/ipc-request.model.ts b/packages/peertube-runner/shared/ipc/shared/ipc-request.model.ts index 0f733cdfe..352808c74 100644 --- a/packages/peertube-runner/shared/ipc/shared/ipc-request.model.ts +++ b/packages/peertube-runner/shared/ipc/shared/ipc-request.model.ts | |||
@@ -11,5 +11,5 @@ export type IPCRequestRegister = { | |||
11 | runnerDescription?: string | 11 | runnerDescription?: string |
12 | } | 12 | } |
13 | 13 | ||
14 | export type IPCRequestUnregister = { type: 'unregister', url: string } | 14 | export type IPCRequestUnregister = { type: 'unregister', url: string, runnerName: string } |
15 | export type IPCRequestListRegistered = { type: 'list-registered' } | 15 | export type IPCRequestListRegistered = { type: 'list-registered' } |
diff --git a/server/tests/peertube-runner/client-cli.ts b/server/tests/peertube-runner/client-cli.ts index cc8136c4a..5cbdc4e77 100644 --- a/server/tests/peertube-runner/client-cli.ts +++ b/server/tests/peertube-runner/client-cli.ts | |||
@@ -53,7 +53,7 @@ describe('Test peertube-runner program client CLI', function () { | |||
53 | }) | 53 | }) |
54 | 54 | ||
55 | it('Should unregister the PeerTube instance', async function () { | 55 | it('Should unregister the PeerTube instance', async function () { |
56 | await peertubeRunner.unregisterPeerTubeInstance() | 56 | await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'my super runner' }) |
57 | }) | 57 | }) |
58 | 58 | ||
59 | it('Should not have PeerTube instance listed', async function () { | 59 | it('Should not have PeerTube instance listed', async function () { |
diff --git a/server/tests/peertube-runner/live-transcoding.ts b/server/tests/peertube-runner/live-transcoding.ts index c2ca1de96..4826c61f7 100644 --- a/server/tests/peertube-runner/live-transcoding.ts +++ b/server/tests/peertube-runner/live-transcoding.ts | |||
@@ -190,7 +190,7 @@ describe('Test Live transcoding in peertube-runner program', function () { | |||
190 | 190 | ||
191 | after(async function () { | 191 | after(async function () { |
192 | if (peertubeRunner) { | 192 | if (peertubeRunner) { |
193 | await peertubeRunner.unregisterPeerTubeInstance() | 193 | await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'runner' }) |
194 | peertubeRunner.kill() | 194 | peertubeRunner.kill() |
195 | } | 195 | } |
196 | 196 | ||
diff --git a/server/tests/peertube-runner/studio-transcoding.ts b/server/tests/peertube-runner/studio-transcoding.ts index 69b38a536..988201947 100644 --- a/server/tests/peertube-runner/studio-transcoding.ts +++ b/server/tests/peertube-runner/studio-transcoding.ts | |||
@@ -115,7 +115,7 @@ describe('Test studio transcoding in peertube-runner program', function () { | |||
115 | 115 | ||
116 | after(async function () { | 116 | after(async function () { |
117 | if (peertubeRunner) { | 117 | if (peertubeRunner) { |
118 | await peertubeRunner.unregisterPeerTubeInstance() | 118 | await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'runner' }) |
119 | peertubeRunner.kill() | 119 | peertubeRunner.kill() |
120 | } | 120 | } |
121 | 121 | ||
diff --git a/server/tests/peertube-runner/vod-transcoding.ts b/server/tests/peertube-runner/vod-transcoding.ts index aefec394d..c3f41c097 100644 --- a/server/tests/peertube-runner/vod-transcoding.ts +++ b/server/tests/peertube-runner/vod-transcoding.ts | |||
@@ -341,7 +341,7 @@ describe('Test VOD transcoding in peertube-runner program', function () { | |||
341 | 341 | ||
342 | after(async function () { | 342 | after(async function () { |
343 | if (peertubeRunner) { | 343 | if (peertubeRunner) { |
344 | await peertubeRunner.unregisterPeerTubeInstance() | 344 | await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'runner' }) |
345 | peertubeRunner.kill() | 345 | peertubeRunner.kill() |
346 | } | 346 | } |
347 | 347 | ||
diff --git a/server/tests/shared/peertube-runner-process.ts b/server/tests/shared/peertube-runner-process.ts index b3c8dfe0e..9304ebcc8 100644 --- a/server/tests/shared/peertube-runner-process.ts +++ b/server/tests/shared/peertube-runner-process.ts | |||
@@ -60,8 +60,12 @@ export class PeerTubeRunnerProcess { | |||
60 | return execa.node(this.getRunnerPath(), args) | 60 | return execa.node(this.getRunnerPath(), args) |
61 | } | 61 | } |
62 | 62 | ||
63 | unregisterPeerTubeInstance () { | 63 | unregisterPeerTubeInstance (options: { |
64 | const args = [ 'unregister', '--url', this.server.url, ...this.buildIdArg() ] | 64 | runnerName: string |
65 | }) { | ||
66 | const { runnerName } = options | ||
67 | |||
68 | const args = [ 'unregister', '--url', this.server.url, '--runner-name', runnerName, ...this.buildIdArg() ] | ||
65 | return execa.node(this.getRunnerPath(), args) | 69 | return execa.node(this.getRunnerPath(), args) |
66 | } | 70 | } |
67 | 71 | ||
diff --git a/support/doc/tools.md b/support/doc/tools.md index c12b00e32..f45a39718 100644 --- a/support/doc/tools.md +++ b/support/doc/tools.md | |||
@@ -398,7 +398,7 @@ The runner will then use a websocket connection with the PeerTube instance to be | |||
398 | To unregister a PeerTube instance: | 398 | To unregister a PeerTube instance: |
399 | 399 | ||
400 | ```bash | 400 | ```bash |
401 | peertube-runner unregister --url http://peertube.example.com | 401 | peertube-runner unregister --url http://peertube.example.com --runner-name my-runner-name |
402 | ``` | 402 | ``` |
403 | 403 | ||
404 | ### List registered instances | 404 | ### List registered instances |