sc-manager/dev.mjs

42 lines
1.2 KiB
JavaScript

import { ServiceCore, Application, getLog, Util, Core } from 'service-core'
import * as index from './index.mjs'
let util = new Util(import.meta.url)
const helloWorldConfig = {
"provider": "git",
"url": "https://git.nfp.is/api/v1/repos/thething/sc-helloworld/releases",
"port": 8888,
}
var core = new ServiceCore('sc-manager', import.meta.url)
core.config['hello-world'] = helloWorldConfig
core.setConfig({
port: 4271,
})
core.init(index).then(function() {
let provConstructor = Core.providers.get(core.db.config['hello-world'].provider)
let provider = new provConstructor(core.db.config['hello-world'])
let helloWorld = new Application({
db: core.db,
util: util,
log: getLog('hello-world'),
core: core.core,
}, provider, 'hello-world')
core.core.applications.push(helloWorld)
core.core.applicationMap.set('hello-world', helloWorld)
helloWorld.startAutoupdater()
return core.run()
}).then(function() {
return core.core.applicationMap.get('hello-world').update()
}).then(function() {
return core.core.runApplication(core.core.applicationMap.get('hello-world'))
}).then(function() {
let helloApp = core.core.applicationMap.get('hello-world')
helloApp.on('updated', core.core.runApplication.bind(core.core, helloApp))
})