fixed ServiceManager not loading kvstore
This commit is contained in:
parent
4ab3d868c1
commit
9541b653b5
@ -17,37 +17,46 @@ class ServiceManager {
|
||||
/**
|
||||
Add a service to be automatically started.
|
||||
**/
|
||||
public static function enable(name:String) {
|
||||
public static function enable(name:String):Outcome<Noise, String> {
|
||||
if (!services.exists(name)) {
|
||||
return; // Service must be started
|
||||
return Failure("Service must be started before enable");
|
||||
}
|
||||
|
||||
var store = KVStore.getStoreForClass();
|
||||
store.load();
|
||||
|
||||
var enabled = store.get("enabled", []);
|
||||
enabled.push(name);
|
||||
store.set("enabled", enabled);
|
||||
|
||||
store.save();
|
||||
|
||||
return Success(Noise);
|
||||
}
|
||||
|
||||
/**
|
||||
Remove a service from being automatically started.
|
||||
**/
|
||||
private static function disable(name:String) {
|
||||
private static function disable(name:String):Outcome<Noise, String> {
|
||||
var store = KVStore.getStoreForClass();
|
||||
store.load();
|
||||
|
||||
var enabled:Array<String> = store.get("enabled");
|
||||
var index = enabled.indexOf(name);
|
||||
if (index == -1) {
|
||||
return;
|
||||
return Failure("Service not found");
|
||||
}
|
||||
|
||||
enabled.splice(index, 1);
|
||||
store.save();
|
||||
|
||||
return Success(Noise);
|
||||
}
|
||||
|
||||
private static function startAllEnabled() {
|
||||
var store = KVStore.getStoreForClass();
|
||||
store.load();
|
||||
|
||||
var enabled:Array<String> = store.get("enabled", []);
|
||||
for (name in enabled) {
|
||||
start(name);
|
||||
|
Loading…
Reference in New Issue
Block a user