fix clone state; example routine
This commit is contained in:
@@ -15,11 +15,12 @@ class hosts extends Service {
|
||||
|
||||
get(name) {
|
||||
const config = this.config[name]
|
||||
config.name = name
|
||||
if ( !config ) {
|
||||
throw new Error(`Could not get host ${name}: No such host configured.`)
|
||||
}
|
||||
|
||||
config.name = name
|
||||
|
||||
if ( config.type === 'localhost' ) {
|
||||
const host = this.app.di().make(LocalHost, config)
|
||||
this._running_hosts.push(host)
|
||||
|
||||
@@ -12,18 +12,21 @@ const Routine = require('../classes/routine/Routine')
|
||||
*/
|
||||
class RoutinesService extends Service {
|
||||
static get services() {
|
||||
return [...super.services, 'app', 'configs', 'hosts']
|
||||
return [...super.services, 'injector', 'configs', 'hosts']
|
||||
}
|
||||
|
||||
async get(name) {
|
||||
this.app.make(Routine)
|
||||
const config = this.configs.get(`routines:${name}`)
|
||||
if ( !config ) {
|
||||
throw new Error(`Unable to find a routine with the name: ${name}`)
|
||||
}
|
||||
|
||||
const hosts = {}
|
||||
for ( const host_name of config.hosts ) {
|
||||
hosts[host_name] = await this.hosts.get(host_name)
|
||||
}
|
||||
|
||||
return new Routine(hosts, config, config.type)
|
||||
return this.injector.make(Routine, hosts, config, config.type)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user