program.command('unregister')
.description('Unregister the runner from PeerTube instance')
.requiredOption('--url <url>', 'PeerTube instance URL', parseUrl)
+ .requiredOption('--runner-name <name>', 'Runner name')
.action(async options => {
try {
await unregisterRunner(options)
export async function unregisterRunner (options: {
url: string
+ runnerName: string
}) {
const client = new IPCClient()
await client.run()
async unregisterRunner (options: {
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) {
- logger.error(`Unknown server ${url} to unregister`)
+ logger.error(`Unknown server ${url} - ${runnerName} to unregister`)
return
}
- logger.info(`Unregistering runner ${server.runnerName} on ${url}...`)
+ logger.info(`Unregistering runner ${runnerName} on ${url}...`)
try {
await server.runners.unregister({ runnerToken: server.runnerToken })
} catch (err) {
- logger.error({ err }, `Cannot unregister runner ${server.runnerName} on ${url}`)
+ logger.error({ err }, `Cannot unregister runner ${runnerName} on ${url}`)
}
this.unloadServer(server)
await this.saveRegisteredInstancesInConf()
- logger.info(`Unregistered runner ${server.runnerName} on ${server.url}`)
+ logger.info(`Unregistered runner ${runnerName} on ${url}`)
}
private unloadServer (server: PeerTubeServer) {
if (code === ServerErrorCode.UNKNOWN_RUNNER_TOKEN) {
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
}
async askUnregister (options: {
url: string
+ runnerName: string
}) {
const req: IPCRequest = {
type: 'unregister',
return undefined
case 'unregister':
- await this.runnerServer.unregisterRunner({ url: req.url })
+ await this.runnerServer.unregisterRunner(pick(req, [ 'url', 'runnerName' ]))
return undefined
case 'list-registered':
runnerDescription?: string
}
-export type IPCRequestUnregister = { type: 'unregister', url: string }
+export type IPCRequestUnregister = { type: 'unregister', url: string, runnerName: string }
export type IPCRequestListRegistered = { type: 'list-registered' }
})
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 () {
after(async function () {
if (peertubeRunner) {
- await peertubeRunner.unregisterPeerTubeInstance()
+ await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'runner' })
peertubeRunner.kill()
}
after(async function () {
if (peertubeRunner) {
- await peertubeRunner.unregisterPeerTubeInstance()
+ await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'runner' })
peertubeRunner.kill()
}
after(async function () {
if (peertubeRunner) {
- await peertubeRunner.unregisterPeerTubeInstance()
+ await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'runner' })
peertubeRunner.kill()
}
return execa.node(this.getRunnerPath(), args)
}
- unregisterPeerTubeInstance () {
- const args = [ 'unregister', '--url', this.server.url, ...this.buildIdArg() ]
+ unregisterPeerTubeInstance (options: {
+ runnerName: string
+ }) {
+ const { runnerName } = options
+
+ const args = [ 'unregister', '--url', this.server.url, '--runner-name', runnerName, ...this.buildIdArg() ]
return execa.node(this.getRunnerPath(), args)
}
To unregister a PeerTube instance:
```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