Add CLI flag for offline mode (using temporary hack with globals)

This commit is contained in:
Cinnamon 2020-01-07 11:53:46 -08:00
parent 769a279daa
commit 2c46cbf6f2
2 changed files with 29 additions and 2 deletions

View File

@ -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 () => {

View File

@ -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)