Merge pull request #43 from fraction/offline
Add CLI flag for offline mode (using temporary hack with globals)
This commit is contained in:
commit
6e831c5b73
12
index.js
12
index.js
|
@ -8,12 +8,19 @@ const path = require('path')
|
|||
|
||||
const config = yargs
|
||||
.env('OASIS')
|
||||
.help('h')
|
||||
.alias('h', 'help')
|
||||
.usage('Usage: $0 [options]')
|
||||
.options('open', {
|
||||
describe: 'Automatically open app in web browser',
|
||||
describe: 'Automatically open app in web browser. Use --no-open to disable.',
|
||||
default: true,
|
||||
type: 'boolean'
|
||||
})
|
||||
.options('offline', {
|
||||
describe: "Don't try to connect to scuttlebutt peers or pubs",
|
||||
default: false,
|
||||
type: 'boolean'
|
||||
})
|
||||
.options('host', {
|
||||
describe: 'Hostname for web app to listen on',
|
||||
default: 'localhost',
|
||||
|
@ -42,6 +49,9 @@ if (config.debug) {
|
|||
process.env.DEBUG = 'oasis,oasis:*'
|
||||
}
|
||||
|
||||
// Awful hack to get the offline config setting deep into src/pages/models/lib/server.js
|
||||
process.env.OASIS_OFFLINE = '' + config.offline
|
||||
|
||||
const app = require('./src/app')
|
||||
|
||||
const start = async () => {
|
||||
|
|
|
@ -1,5 +1,22 @@
|
|||
const ssbConfig = require('ssb-config')
|
||||
const flotilla = require('@fraction/flotilla')
|
||||
const debug = require('debug')('oasis')
|
||||
|
||||
// Awful hack to get make offline CLI flag available here.
|
||||
// It's set in index.js
|
||||
const offline = process.env.OASIS_OFFLINE === 'true'
|
||||
if (offline) {
|
||||
debug.enabled = true
|
||||
debug('Offline mode activated - not connecting to scuttlebutt peers or pubs')
|
||||
}
|
||||
|
||||
const server = flotilla({
|
||||
conn: {
|
||||
autostart: !offline
|
||||
},
|
||||
ws: {
|
||||
http: false
|
||||
}
|
||||
})
|
||||
|
||||
const server = flotilla({ ws: { http: false } })
|
||||
server(ssbConfig)
|
||||
|
|
Loading…
Reference in New Issue