-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·37 lines (29 loc) · 963 Bytes
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env node
const process = require('process');
const http = require('patchbay-http');
const { createHandler } = require('remfs-server');
const args = process.argv
.slice(2)
.map(arg => arg.split('='))
.reduce((args, [value, key]) => {
args[value] = key;
return args;
}, {});
if (!args['--root']) {
console.log("Usage: patchbay-remfs-server --root=ROOT_CHANNEL [--token=[AUTH_TOKEN]");
process.exit(1);
}
const rootChannel = args['--root'];
const rootPath = '/req' + rootChannel;
(async () => {
const remfsHandler = await createHandler({ rootPath, dir: args['--dir'] });
const httpServer = http.createServer(remfsHandler);
httpServer.setPatchbayServer('https://patchbay.pub');
//httpServer.setPatchbayServer('http://localhost:9001');
httpServer.setPatchbayChannel(rootChannel);
httpServer.setNumWorkers(4);
if (args['--token']) {
httpServer.setAuthToken(args['--token']);
}
httpServer.listen();
})();