diff options
author | Chocobozzz <me@florianbigard.com> | 2023-05-16 09:24:31 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-05-16 09:27:49 +0200 |
commit | 0d6a8289fb5ce7466f74a0514b3a6e620bfa2e59 (patch) | |
tree | 1a31b31352e633da620ab4510e8c3bbafeb15a4f | |
parent | 287057050526e1f474c4f4d5d9a7ef3b7c677f2f (diff) | |
download | PeerTube-0d6a8289fb5ce7466f74a0514b3a6e620bfa2e59.tar.gz PeerTube-0d6a8289fb5ce7466f74a0514b3a6e620bfa2e59.tar.zst PeerTube-0d6a8289fb5ce7466f74a0514b3a6e620bfa2e59.zip |
Better runner error UX when server is not run
-rw-r--r-- | packages/peertube-runner/peertube-runner.ts | 11 | ||||
-rw-r--r-- | packages/peertube-runner/shared/ipc/ipc-client.ts | 15 | ||||
-rw-r--r-- | support/doc/tools.md | 4 |
3 files changed, 23 insertions, 7 deletions
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') | |||
31 | try { | 31 | try { |
32 | await RunnerServer.Instance.run() | 32 | await RunnerServer.Instance.run() |
33 | } catch (err) { | 33 | } catch (err) { |
34 | logger.error('Cannot run PeerTube runner as server mode', err) | 34 | logger.error(err, 'Cannot run PeerTube runner as server mode') |
35 | process.exit(-1) | 35 | process.exit(-1) |
36 | } | 36 | } |
37 | }) | 37 | }) |
@@ -46,7 +46,8 @@ program.command('register') | |||
46 | try { | 46 | try { |
47 | await registerRunner(options) | 47 | await registerRunner(options) |
48 | } catch (err) { | 48 | } catch (err) { |
49 | logger.error('Cannot register this PeerTube runner.', err) | 49 | console.error('Cannot register this PeerTube runner.') |
50 | console.error(err) | ||
50 | process.exit(-1) | 51 | process.exit(-1) |
51 | } | 52 | } |
52 | }) | 53 | }) |
@@ -58,7 +59,8 @@ program.command('unregister') | |||
58 | try { | 59 | try { |
59 | await unregisterRunner(options) | 60 | await unregisterRunner(options) |
60 | } catch (err) { | 61 | } catch (err) { |
61 | logger.error('Cannot unregister this PeerTube runner.', err) | 62 | console.error('Cannot unregister this PeerTube runner.') |
63 | console.error(err) | ||
62 | process.exit(-1) | 64 | process.exit(-1) |
63 | } | 65 | } |
64 | }) | 66 | }) |
@@ -69,7 +71,8 @@ program.command('list-registered') | |||
69 | try { | 71 | try { |
70 | await listRegistered() | 72 | await listRegistered() |
71 | } catch (err) { | 73 | } catch (err) { |
72 | logger.error('Cannot list registered PeerTube instances.', err) | 74 | console.error('Cannot list registered PeerTube instances.') |
75 | console.error(err) | ||
73 | process.exit(-1) | 76 | process.exit(-1) |
74 | } | 77 | } |
75 | }) | 78 | }) |
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 { | |||
11 | await ensureDir(ConfigManager.Instance.getSocketDirectory()) | 11 | await ensureDir(ConfigManager.Instance.getSocketDirectory()) |
12 | 12 | ||
13 | const socketPath = ConfigManager.Instance.getSocketPath() | 13 | const socketPath = ConfigManager.Instance.getSocketPath() |
14 | |||
14 | this.netIPC = new NetIPC({ path: socketPath }) | 15 | this.netIPC = new NetIPC({ path: socketPath }) |
15 | await this.netIPC.connect() | 16 | |
17 | try { | ||
18 | await this.netIPC.connect() | ||
19 | } catch (err) { | ||
20 | if (err.code === 'ECONNREFUSED') { | ||
21 | throw new Error( | ||
22 | 'This runner is not currently running in server mode on this system. ' + | ||
23 | 'Please run it using the `server` command first (in another terminal for example) and then retry your command.' | ||
24 | ) | ||
25 | } | ||
26 | |||
27 | throw err | ||
28 | } | ||
16 | } | 29 | } |
17 | 30 | ||
18 | async askRegister (options: { | 31 | async askRegister (options: { |
diff --git a/support/doc/tools.md b/support/doc/tools.md index c86f0d12b..5ddef5c5a 100644 --- a/support/doc/tools.md +++ b/support/doc/tools.md | |||
@@ -376,7 +376,7 @@ peertube-runner [commands] --id instance-3 | |||
376 | 376 | ||
377 | ### Run the server | 377 | ### Run the server |
378 | 378 | ||
379 | Run the runner in server mode so it can run transcoding jobs of registered PeerTube instances: | 379 | You need to run the runner in server mode first so it can run transcoding jobs of registered PeerTube instances: |
380 | 380 | ||
381 | ```bash | 381 | ```bash |
382 | peertube-runner server | 382 | peertube-runner server |
@@ -384,7 +384,7 @@ peertube-runner server | |||
384 | 384 | ||
385 | ### Register | 385 | ### Register |
386 | 386 | ||
387 | To register the runner on a new PeerTube instance so the runner can process its transcoding job: | 387 | Then, you can register the runner on a new PeerTube instance so the runner can process its transcoding job: |
388 | 388 | ||
389 | ```bash | 389 | ```bash |
390 | peertube-runner register --url http://peertube.example.com --registration-token ptrrt-... --runner-name my-runner-name | 390 | peertube-runner register --url http://peertube.example.com --registration-token ptrrt-... --runner-name my-runner-name |