forked from ssb-junkyard/ssb-minimal-pub-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
50 lines (41 loc) · 1.51 KB
/
server.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
38
39
40
41
42
43
44
45
46
47
48
49
50
const fs = require('fs')
const ProgressBar = require('./lib/progress')
const runServer = (config, manifestFile, cb) => {
const packageJson = require('./package.json')
console.log(`running server`)
console.log(packageJson.name, packageJson.version, config.path, 'logging.level:' + config.logging.level)
console.log(`my key ID: ${config.keys.public}`)
const createSsbServer = require('./')
.use(require('ssb-onion'))
.use(require('ssb-unix-socket'))
.use(require('ssb-no-auth'))
.use(require('ssb-plugins'))
.use(require('ssb-master'))
.use(require('ssb-legacy-conn'))
.use(require('ssb-replicate'))
.use(require('ssb-friends'))
.use(require('ssb-blobs'))
.use(require('ssb-invite'))
.use(require('ssb-local'))
.use(require('ssb-logging'))
.use(require('ssb-query'))
.use(require('ssb-ws'))
.use(require('ssb-ebt'))
.use(require('ssb-ooo'))
// add third-party plugins
require('ssb-plugins').loadUserPlugins(createSsbServer, config)
const server = createSsbServer(config)
// write RPC manifest to ~/.${ssb_appname}/manifest.json
fs.writeFileSync(manifestFile, JSON.stringify(server.getManifest(), null, 2))
if (cb) {
setInterval(() => {
const progress = server.progress()
if (progress) cb()
}, 10)
setTimeout(() => {
cb(new Error(`Timed out starting server after 10 seconds`))
}, 10 * 1000)
}
if (process.stdout.isTTY && (config.logging.level !== 'info')) { ProgressBar(server.progress) }
}
module.exports = runServer