diff --git a/src/bin/HelloWorldService.hx b/src/bin/HelloWorldService.hx index cd67c55..7cfd0a2 100644 --- a/src/bin/HelloWorldService.hx +++ b/src/bin/HelloWorldService.hx @@ -1,5 +1,6 @@ package bin; +import kernel.service.ServiceManager; import kernel.log.Log; import kernel.Timer; import kernel.ps.ProcessHandle; @@ -11,7 +12,9 @@ class HelloWorldService implements Process { public function run(handle:ProcessHandle) { Log.debug("HelloWorldService started"); handle.write("Hello World! Started\n"); - this.startTimer(handle); + // this.startTimer(handle); + var srv: HelloWorldService = ServiceManager.instance.get("HelloWorldService"); + srv.startTimer(handle); } public function startTimer(handle: ProcessHandle) { diff --git a/src/kernel/service/Service.hx b/src/kernel/service/Service.hx index cce3b8b..7262367 100644 --- a/src/kernel/service/Service.hx +++ b/src/kernel/service/Service.hx @@ -1,16 +1,17 @@ package kernel.service; +import kernel.ps.Process; import kernel.ps.ProcessManager; -import kernel.ps.ProcessHandle; import kernel.binstore.BinStore; using tink.CoreApi; class Service { - private final binName:String; - private final name:String; - private final args:Array; - private var pid:PID; + public final binName:String; + public final name:String; + public final args:Array; + public var pid:PID; + public var ps: Process; @:allow(kernel.service.ServiceManager) private function new(binName: String,name: String,?args: Array ) { @@ -26,9 +27,9 @@ class Service { throw new Error('Bin ${this.binName} not found'); } - var ps = Type.createInstance(bin.c,this.args); + this.ps = Type.createInstance(bin.c,this.args); - this.pid = ProcessManager.run(ps,{}); + this.pid = ProcessManager.run(this.ps,{}); } public function stop() { diff --git a/src/kernel/service/ServiceManager.hx b/src/kernel/service/ServiceManager.hx index 2135547..002b7b4 100644 --- a/src/kernel/service/ServiceManager.hx +++ b/src/kernel/service/ServiceManager.hx @@ -128,4 +128,16 @@ class ServiceManager { } return running; } + + public function get(name: String): Null { + if (!this.services.exists(name)){ + return null; + } + + // TODO: Maybe there is a way to check types here? + + var srv = this.services.get(name); + return srv.ps; + } + }