diff --git a/src/kernel/service/ServiceManager.hx b/src/kernel/service/ServiceManager.hx index d867f98..b45d4b1 100644 --- a/src/kernel/service/ServiceManager.hx +++ b/src/kernel/service/ServiceManager.hx @@ -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 { 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 { var store = KVStore.getStoreForClass(); + store.load(); + var enabled:Array = 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 = store.get("enabled", []); for (name in enabled) { start(name);