Specify runner name when unregistering the runner
This commit is contained in:
parent
e35967ee08
commit
f474a519dc
|
@ -55,6 +55,7 @@ program.command('register')
|
||||||
program.command('unregister')
|
program.command('unregister')
|
||||||
.description('Unregister the runner from PeerTube instance')
|
.description('Unregister the runner from PeerTube instance')
|
||||||
.requiredOption('--url <url>', 'PeerTube instance URL', parseUrl)
|
.requiredOption('--url <url>', 'PeerTube instance URL', parseUrl)
|
||||||
|
.requiredOption('--runner-name <name>', 'Runner name')
|
||||||
.action(async options => {
|
.action(async options => {
|
||||||
try {
|
try {
|
||||||
await unregisterRunner(options)
|
await unregisterRunner(options)
|
||||||
|
|
|
@ -16,6 +16,7 @@ export async function registerRunner (options: {
|
||||||
|
|
||||||
export async function unregisterRunner (options: {
|
export async function unregisterRunner (options: {
|
||||||
url: string
|
url: string
|
||||||
|
runnerName: string
|
||||||
}) {
|
}) {
|
||||||
const client = new IPCClient()
|
const client = new IPCClient()
|
||||||
await client.run()
|
await client.run()
|
||||||
|
|
|
@ -121,27 +121,28 @@ export class RunnerServer {
|
||||||
|
|
||||||
async unregisterRunner (options: {
|
async unregisterRunner (options: {
|
||||||
url: string
|
url: string
|
||||||
|
runnerName: string
|
||||||
}) {
|
}) {
|
||||||
const { url } = options
|
const { url, runnerName } = options
|
||||||
|
|
||||||
const server = this.servers.find(s => s.url === url)
|
const server = this.servers.find(s => s.url === url && s.runnerName === runnerName)
|
||||||
if (!server) {
|
if (!server) {
|
||||||
logger.error(`Unknown server ${url} to unregister`)
|
logger.error(`Unknown server ${url} - ${runnerName} to unregister`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`Unregistering runner ${server.runnerName} on ${url}...`)
|
logger.info(`Unregistering runner ${runnerName} on ${url}...`)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await server.runners.unregister({ runnerToken: server.runnerToken })
|
await server.runners.unregister({ runnerToken: server.runnerToken })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error({ err }, `Cannot unregister runner ${server.runnerName} on ${url}`)
|
logger.error({ err }, `Cannot unregister runner ${runnerName} on ${url}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.unloadServer(server)
|
this.unloadServer(server)
|
||||||
await this.saveRegisteredInstancesInConf()
|
await this.saveRegisteredInstancesInConf()
|
||||||
|
|
||||||
logger.info(`Unregistered runner ${server.runnerName} on ${server.url}`)
|
logger.info(`Unregistered runner ${runnerName} on ${url}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
private unloadServer (server: PeerTubeServer) {
|
private unloadServer (server: PeerTubeServer) {
|
||||||
|
@ -195,7 +196,7 @@ export class RunnerServer {
|
||||||
if (code === ServerErrorCode.UNKNOWN_RUNNER_TOKEN) {
|
if (code === ServerErrorCode.UNKNOWN_RUNNER_TOKEN) {
|
||||||
logger.error({ err }, `Unregistering ${server.url} as the runner token ${server.runnerToken} is invalid`)
|
logger.error({ err }, `Unregistering ${server.url} as the runner token ${server.runnerToken} is invalid`)
|
||||||
|
|
||||||
await this.unregisterRunner({ url: server.url })
|
await this.unregisterRunner({ url: server.url, runnerName: server.runnerName })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ export class IPCClient {
|
||||||
|
|
||||||
async askUnregister (options: {
|
async askUnregister (options: {
|
||||||
url: string
|
url: string
|
||||||
|
runnerName: string
|
||||||
}) {
|
}) {
|
||||||
const req: IPCRequest = {
|
const req: IPCRequest = {
|
||||||
type: 'unregister',
|
type: 'unregister',
|
||||||
|
|
|
@ -40,7 +40,7 @@ export class IPCServer {
|
||||||
return undefined
|
return undefined
|
||||||
|
|
||||||
case 'unregister':
|
case 'unregister':
|
||||||
await this.runnerServer.unregisterRunner({ url: req.url })
|
await this.runnerServer.unregisterRunner(pick(req, [ 'url', 'runnerName' ]))
|
||||||
return undefined
|
return undefined
|
||||||
|
|
||||||
case 'list-registered':
|
case 'list-registered':
|
||||||
|
|
|
@ -11,5 +11,5 @@ export type IPCRequestRegister = {
|
||||||
runnerDescription?: string
|
runnerDescription?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type IPCRequestUnregister = { type: 'unregister', url: string }
|
export type IPCRequestUnregister = { type: 'unregister', url: string, runnerName: string }
|
||||||
export type IPCRequestListRegistered = { type: 'list-registered' }
|
export type IPCRequestListRegistered = { type: 'list-registered' }
|
||||||
|
|
|
@ -53,7 +53,7 @@ describe('Test peertube-runner program client CLI', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should unregister the PeerTube instance', async function () {
|
it('Should unregister the PeerTube instance', async function () {
|
||||||
await peertubeRunner.unregisterPeerTubeInstance()
|
await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'my super runner' })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not have PeerTube instance listed', async function () {
|
it('Should not have PeerTube instance listed', async function () {
|
||||||
|
|
|
@ -190,7 +190,7 @@ describe('Test Live transcoding in peertube-runner program', function () {
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
if (peertubeRunner) {
|
if (peertubeRunner) {
|
||||||
await peertubeRunner.unregisterPeerTubeInstance()
|
await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'runner' })
|
||||||
peertubeRunner.kill()
|
peertubeRunner.kill()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ describe('Test studio transcoding in peertube-runner program', function () {
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
if (peertubeRunner) {
|
if (peertubeRunner) {
|
||||||
await peertubeRunner.unregisterPeerTubeInstance()
|
await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'runner' })
|
||||||
peertubeRunner.kill()
|
peertubeRunner.kill()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -341,7 +341,7 @@ describe('Test VOD transcoding in peertube-runner program', function () {
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
if (peertubeRunner) {
|
if (peertubeRunner) {
|
||||||
await peertubeRunner.unregisterPeerTubeInstance()
|
await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'runner' })
|
||||||
peertubeRunner.kill()
|
peertubeRunner.kill()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,12 @@ export class PeerTubeRunnerProcess {
|
||||||
return execa.node(this.getRunnerPath(), args)
|
return execa.node(this.getRunnerPath(), args)
|
||||||
}
|
}
|
||||||
|
|
||||||
unregisterPeerTubeInstance () {
|
unregisterPeerTubeInstance (options: {
|
||||||
const args = [ 'unregister', '--url', this.server.url, ...this.buildIdArg() ]
|
runnerName: string
|
||||||
|
}) {
|
||||||
|
const { runnerName } = options
|
||||||
|
|
||||||
|
const args = [ 'unregister', '--url', this.server.url, '--runner-name', runnerName, ...this.buildIdArg() ]
|
||||||
return execa.node(this.getRunnerPath(), args)
|
return execa.node(this.getRunnerPath(), args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -398,7 +398,7 @@ The runner will then use a websocket connection with the PeerTube instance to be
|
||||||
To unregister a PeerTube instance:
|
To unregister a PeerTube instance:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
peertube-runner unregister --url http://peertube.example.com
|
peertube-runner unregister --url http://peertube.example.com --runner-name my-runner-name
|
||||||
```
|
```
|
||||||
|
|
||||||
### List registered instances
|
### List registered instances
|
||||||
|
|
Loading…
Reference in New Issue