From 0d6a8289fb5ce7466f74a0514b3a6e620bfa2e59 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 16 May 2023 09:24:31 +0200 Subject: Better runner error UX when server is not run --- packages/peertube-runner/peertube-runner.ts | 11 +++++++---- packages/peertube-runner/shared/ipc/ipc-client.ts | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'packages') diff --git a/packages/peertube-runner/peertube-runner.ts b/packages/peertube-runner/peertube-runner.ts index 9c3e498d6..858d85e6a 100644 --- a/packages/peertube-runner/peertube-runner.ts +++ b/packages/peertube-runner/peertube-runner.ts @@ -31,7 +31,7 @@ program.command('server') try { await RunnerServer.Instance.run() } catch (err) { - logger.error('Cannot run PeerTube runner as server mode', err) + logger.error(err, 'Cannot run PeerTube runner as server mode') process.exit(-1) } }) @@ -46,7 +46,8 @@ program.command('register') try { await registerRunner(options) } catch (err) { - logger.error('Cannot register this PeerTube runner.', err) + console.error('Cannot register this PeerTube runner.') + console.error(err) process.exit(-1) } }) @@ -58,7 +59,8 @@ program.command('unregister') try { await unregisterRunner(options) } catch (err) { - logger.error('Cannot unregister this PeerTube runner.', err) + console.error('Cannot unregister this PeerTube runner.') + console.error(err) process.exit(-1) } }) @@ -69,7 +71,8 @@ program.command('list-registered') try { await listRegistered() } catch (err) { - logger.error('Cannot list registered PeerTube instances.', err) + console.error('Cannot list registered PeerTube instances.') + console.error(err) process.exit(-1) } }) diff --git a/packages/peertube-runner/shared/ipc/ipc-client.ts b/packages/peertube-runner/shared/ipc/ipc-client.ts index 7f5951157..db8d7f1bf 100644 --- a/packages/peertube-runner/shared/ipc/ipc-client.ts +++ b/packages/peertube-runner/shared/ipc/ipc-client.ts @@ -11,8 +11,21 @@ export class IPCClient { await ensureDir(ConfigManager.Instance.getSocketDirectory()) const socketPath = ConfigManager.Instance.getSocketPath() + this.netIPC = new NetIPC({ path: socketPath }) - await this.netIPC.connect() + + try { + await this.netIPC.connect() + } catch (err) { + if (err.code === 'ECONNREFUSED') { + throw new Error( + 'This runner is not currently running in server mode on this system. ' + + 'Please run it using the `server` command first (in another terminal for example) and then retry your command.' + ) + } + + throw err + } } async askRegister (options: { -- cgit v1.2.3