feat(xo-server/Xo): pass appDir, AppName and httpServer

As done in xo-proxy.

This may allow sharing mixins in the future.
This commit is contained in:
Julien Fontanet
2021-04-07 10:28:33 +02:00
parent ce09f487bd
commit 1c9b4cf552

View File

@@ -67,13 +67,14 @@ const log = createLogger('xo:main')
// ===================================================================
const APP_DIR = joinPath(__dirname, '..')
const APP_NAME = 'xo-server'
const DEPRECATED_ENTRIES = ['users', 'servers']
async function loadConfiguration() {
const config = await appConf.load(APP_NAME, {
appDir: joinPath(__dirname, '..'),
appDir: APP_DIR,
ignoreUnknownFormats: true,
})
@@ -720,7 +721,13 @@ export default async function main(args) {
const safeMode = includes(args, '--safe-mode')
// Creates main object.
const xo = new Xo({ config, safeMode })
const xo = new Xo({
appDir: APP_DIR,
appName: APP_NAME,
config,
httpServer: webServer,
safeMode,
})
// Register web server close on XO stop.
xo.on('stop', () => fromCallback.call(webServer, 'stop'))