forked from ssbc/patchwork
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver-process.js
More file actions
73 lines (67 loc) · 2.12 KB
/
Copy pathserver-process.js
File metadata and controls
73 lines (67 loc) · 2.12 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
var fs = require('fs')
var Path = require('path')
var electron = require('electron')
var spawn = require('child_process').spawn
var fixPath = require('fix-path')
// var DHT = require('multiserver-dht')
// removing DHT invites until they work in sbot@13
//
// function dhtTransport (sbot) {
// sbot.multiserver.transport({
// name: 'dht',
// create: dhtConfig => {
// return DHT({
// keys: sbot.dhtInvite.channels(),
// port: dhtConfig.por t
// })
// }
// })
// }
var createSbot = require('secret-stack')()
.use(require('ssb-db'))
.use(require('ssb-master'))
.use(require('ssb-gossip'))
.use(require('ssb-replicate'))
.use(require('ssb-no-auth'))
.use(require('ssb-unix-socket'))
// .use(require('ssb-friends')) // woah! (being handled in sbot/index.js and sbot/contacts.js)
.use(require('ssb-blobs'))
.use(require('ssb-backlinks'))
.use(require('ssb-about'))
.use(require('ssb-private'))
// .use(require('ssb-dht-invite')) // this one must come before dhtTransport
// .use(dhtTransport)
.use(require('ssb-invite'))
.use(require('ssb-local'))
.use(require('ssb-logging'))
.use(require('ssb-query'))
.use(require('ssb-search'))
.use(require('ssb-ws'))
.use(require('ssb-tags'))
// .use(require('ssb-ebt')) // enable at your own risk!
.use(require('./sbot'))
fixPath()
module.exports = function (ssbConfig) {
var context = {
sbot: createSbot(ssbConfig),
config: ssbConfig
}
ssbConfig.manifest = context.sbot.getManifest()
fs.writeFileSync(Path.join(ssbConfig.path, 'manifest.json'), JSON.stringify(ssbConfig.manifest))
electron.ipcRenderer.send('server-started', ssbConfig)
// start dht invite support
// context.sbot.dhtInvite.start()
// check if we are using a custom ssb path (which would break git-ssb-web)
if (!ssbConfig.customPath) {
// attempt to run git-ssb if it is installed and in path
var gitSsb = spawn('git-ssb', [ 'web' ], {
stdio: 'inherit'
})
gitSsb.on('error', () => {
console.log('git-ssb is not installed, or not available in path')
})
process.on('exit', () => {
gitSsb.kill()
})
}
}