parent
8319859828
commit
2c0b126546
@ -0,0 +1,43 @@
|
||||
const units = require('./Units.flitter')
|
||||
delete units.App
|
||||
|
||||
const FlitterApp = require('libflitter/app/FlitterApp')
|
||||
const app = new FlitterApp(units)
|
||||
const services = app.di().container.proxy()
|
||||
let ready = false
|
||||
let ready_ps = []
|
||||
|
||||
app.up().then(() => {
|
||||
ready = true
|
||||
ready_ps.forEach(x => x())
|
||||
})
|
||||
|
||||
module.exports = exports = {
|
||||
app,
|
||||
services,
|
||||
UniversalPath: require('./app/classes/logical/UniversalPath'),
|
||||
ready: () => ready,
|
||||
ready$: async () => {
|
||||
if ( !ready )
|
||||
return new Promise(res => ready_ps.push(res))
|
||||
},
|
||||
host(name_or_config) {
|
||||
if ( typeof name_or_config === 'object' ) {
|
||||
if ( !name_or_config.name )
|
||||
throw new TypeError('Missing required host property: name')
|
||||
|
||||
if ( services.configs.canonical_items.hosts[name_or_config.name] )
|
||||
throw new TypeError(`A host with the name ${name_or_config.name} is already registered.`)
|
||||
|
||||
services.configs.canonical_items.hosts[name_or_config.name] = name_or_config
|
||||
console.log(services.configs.canonical_items.hosts)
|
||||
return services.hosts.get(name_or_config.name)
|
||||
}
|
||||
|
||||
return services.hosts.get(name_or_config)
|
||||
},
|
||||
}
|
||||
|
||||
exports.ready$().then(() => {
|
||||
app.di().inject(exports.UniversalPath)
|
||||
})
|
@ -0,0 +1,19 @@
|
||||
const ConfigUnit = require('libflitter/config/ConfigUnit')
|
||||
const path = require('path')
|
||||
|
||||
class CompatConfigUnit extends ConfigUnit {
|
||||
/**
|
||||
* Get the name of the service provided by this unit: 'services'
|
||||
* @returns {string} - 'services'
|
||||
*/
|
||||
static get name() {
|
||||
return 'configs'
|
||||
}
|
||||
|
||||
constructor() {
|
||||
const base_dir = path.resolve(__dirname, '..', '..', 'config')
|
||||
super(base_dir)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = CompatConfigUnit
|
@ -0,0 +1,19 @@
|
||||
const ServicesUnit = require('libflitter/services/ServicesUnit')
|
||||
const path = require('path')
|
||||
|
||||
class CompatServicesUnit extends ServicesUnit {
|
||||
/**
|
||||
* Get the name of the service provided by this unit: 'services'
|
||||
* @returns {string} - 'services'
|
||||
*/
|
||||
static get name() {
|
||||
return 'services'
|
||||
}
|
||||
|
||||
constructor() {
|
||||
const base_dir = path.resolve(__dirname, '..', 'services')
|
||||
super(base_dir)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exports = CompatServicesUnit
|
@ -1,48 +1,31 @@
|
||||
// hosts Configuration
|
||||
const hosts = {
|
||||
|
||||
localhost: {
|
||||
type: 'localhost',
|
||||
packages: {
|
||||
type: 'dnf',
|
||||
},
|
||||
services: {
|
||||
type: 'systemd',
|
||||
},
|
||||
},
|
||||
|
||||
core: {
|
||||
type: 'ssh',
|
||||
ssh_params: {
|
||||
port: 60022,
|
||||
username: 'root',
|
||||
host: 'core.infrastructure',
|
||||
key_file: '/home/garrettmills/.ssh/id_rsa',
|
||||
},
|
||||
packages: {
|
||||
type: 'apt',
|
||||
},
|
||||
services: {
|
||||
type: 'systemd',
|
||||
},
|
||||
},
|
||||
|
||||
edge: {
|
||||
type: 'ssh',
|
||||
ssh_params: {
|
||||
port: 60022,
|
||||
username: 'root',
|
||||
host: 'edge.infrastructure',
|
||||
key_file: '/home/garrettmills/.ssh/id_rsa',
|
||||
},
|
||||
packages: {
|
||||
type: 'apt',
|
||||
},
|
||||
services: {
|
||||
type: 'systemd',
|
||||
},
|
||||
},
|
||||
// localhost: {
|
||||
// type: 'localhost',
|
||||
// packages: {
|
||||
// type: 'dnf',
|
||||
// },
|
||||
// services: {
|
||||
// type: 'systemd',
|
||||
// },
|
||||
// },
|
||||
|
||||
// core: {
|
||||
// type: 'ssh',
|
||||
// ssh_params: {
|
||||
// port: 60022,
|
||||
// username: 'root',
|
||||
// host: 'core',
|
||||
// key_file: '/home/user/.ssh/id_rsa',
|
||||
// },
|
||||
// packages: {
|
||||
// type: 'apt', // apt | dnf
|
||||
// },
|
||||
// services: {
|
||||
// type: 'systemd', // systemd
|
||||
// },
|
||||
// },
|
||||
}
|
||||
|
||||
module.exports = exports = hosts
|
||||
|
Loading…
Reference in new issue