git ssb

2+

mixmix / ticktack



Tree: ba050d296a338574b378e2dcc8d67060d46b6fea

Files: ba050d296a338574b378e2dcc8d67060d46b6fea / background-process.js

1757 bytesRaw
1const fs = require('fs')
2const Path = require('path')
3const electron = require('electron')
4const Client = require('ssb-client')
5
6// pull config options out of depject
7const config = require('./config').create().config.sync.load()
8
9var createSbot = require('scuttlebot')
10 .use(require('scuttlebot/plugins/master'))
11 .use(require('scuttlebot/plugins/gossip'))
12 .use(require('scuttlebot/plugins/replicate'))
13 .use(require('ssb-friends'))
14 .use(require('ssb-blobs'))
15 .use(require('ssb-backlinks'))
16 .use(require('ssb-private'))
17 .use(require('scuttlebot/plugins/invite'))
18 .use(require('scuttlebot/plugins/local'))
19 .use(require('scuttlebot/plugins/logging'))
20 .use(require('ssb-query'))
21 .use(require('ssb-about'))
22 .use(require('ssb-ebt'))
23 .use(require('ssb-ws'))
24 .use(require('ssb-server-channel'))
25 .use(require('./ssb-server-ticktack'))
26
27const manifestPath = Path.join(Path.join(config.path), 'manifest.json')
28const isNewInstall = !fs.existsSync(manifestPath)
29
30if (isNewInstall) startSbot()
31else {
32 // see if we can connect to an existing sbot on this config
33 Client(config.keys, config, (err, server) => {
34 // err implies no, we should start an sbot
35 if (err) startSbot()
36 else {
37 // there's already and sbot running and we've connected to it
38 console.log('> sbot running elsewhere')
39 server.close() // close this client connection (app starts one of its own)
40 electron.ipcRenderer.send('server-started')
41 }
42 })
43}
44
45function startSbot () {
46 console.log('> starting sbot')
47 var sbot = createSbot(config)
48
49 console.log(' > updating updating manifest.json')
50 var manifest = sbot.getManifest()
51 fs.writeFileSync(manifestPath, JSON.stringify(manifest))
52 electron.ipcRenderer.send('server-started')
53}
54

Built with git-ssb-web