git ssb

1+

Daan Patchwork / patchwork



Tree: 58ab0241031aa549a35cce1e678c27065ae66221

Files: 58ab0241031aa549a35cce1e678c27065ae66221 / lib / server-process.js

2178 bytesRaw
1const fs = require('fs')
2const Path = require('path')
3const electron = require('electron')
4const spawn = require('child_process').spawn
5const fixPath = require('fix-path')
6// var DHT = require('multiserver-dht')
7
8// removing DHT invites until they work in sbot@13
9//
10// function dhtTransport (sbot) {
11// sbot.multiserver.transport({
12// name: 'dht',
13// create: dhtConfig => {
14// return DHT({
15// keys: sbot.dhtInvite.channels(),
16// port: dhtConfig.por t
17// })
18// }
19// })
20// }
21
22const createSbot = require('secret-stack')()
23 .use(require('ssb-db'))
24 .use(require('ssb-conn'))
25 .use(require('ssb-lan'))
26 .use(require('ssb-logging'))
27 .use(require('ssb-master'))
28 .use(require('ssb-no-auth'))
29 .use(require('ssb-replicate'))
30 .use(require('ssb-unix-socket'))
31 .use(require('ssb-friends')) // not strictly required, but helps ssb-conn a lot
32 .use(require('ssb-blobs'))
33 .use(require('ssb-backlinks'))
34 .use(require('ssb-about'))
35 .use(require('ssb-private'))
36 .use(require('ssb-room/tunnel/client'))
37 // .use(require('ssb-dht-invite')) // this one must come before dhtTransport
38 // .use(dhtTransport)
39 .use(require('ssb-invite'))
40 .use(require('ssb-query'))
41 .use(require('ssb-search'))
42 .use(require('ssb-ws'))
43 .use(require('ssb-tags'))
44 .use(require('ssb-ebt'))
45 .use(require('./plugins'))
46
47fixPath()
48
49module.exports = function (ssbConfig) {
50 const context = {
51 sbot: createSbot(ssbConfig),
52 config: ssbConfig
53 }
54 ssbConfig.manifest = context.sbot.getManifest()
55 fs.writeFileSync(Path.join(ssbConfig.path, 'manifest.json'), JSON.stringify(ssbConfig.manifest))
56 electron.ipcRenderer.send('server-started', ssbConfig)
57
58 // start dht invite support
59 // context.sbot.dhtInvite.start()
60
61 // check if we are using a custom ssb path (which would break git-ssb-web)
62 if (!ssbConfig.customPath) {
63 // attempt to run git-ssb if it is installed and in path
64 const gitSsb = spawn('git-ssb', ['web'], {
65 stdio: 'inherit'
66 })
67 gitSsb.on('error', () => {
68 console.log('git-ssb is not installed, or not available in path')
69 })
70 process.on('exit', () => {
71 gitSsb.kill()
72 })
73 }
74}
75

Built with git-ssb-web