added service bin
This commit is contained in:
parent
f35c98f912
commit
5985b0c8be
63
src/bin/Service.hx
Normal file
63
src/bin/Service.hx
Normal file
@ -0,0 +1,63 @@
|
||||
package bin;
|
||||
|
||||
import kernel.service.ServiceManager;
|
||||
import lib.CLIAppBase;
|
||||
|
||||
using tink.CoreApi;
|
||||
|
||||
class Service extends CLIAppBase {
|
||||
public function new() {
|
||||
registerSyncSubcommand("start", (args) ->{
|
||||
if (args.length < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var name = args[0];
|
||||
|
||||
var result = ServiceManager.instace.start(name);
|
||||
return handleResult(result);
|
||||
},"Start a service");
|
||||
|
||||
registerSyncSubcommand("stop", (args) ->{
|
||||
if (args.length < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var name = args[0];
|
||||
|
||||
var result = ServiceManager.instace.stop(name);
|
||||
return handleResult(result);
|
||||
},"Stop a service");
|
||||
|
||||
registerSyncSubcommand("register", (args) ->{
|
||||
if (args.length < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var name = args[0];
|
||||
var binName = args[1];
|
||||
var rest = args.slice(2);
|
||||
|
||||
var result = ServiceManager.instace.register(name, binName, rest);
|
||||
return handleResult(result);
|
||||
},"Register a new service");
|
||||
|
||||
registerSyncSubcommand("unregister", (args) ->{
|
||||
return true;
|
||||
},"Unregister a service");
|
||||
|
||||
registerSyncSubcommand("list", (args) ->{
|
||||
return true;
|
||||
},"List all services");
|
||||
}
|
||||
|
||||
private function handleResult(res: Outcome<Noise,String>): Bool {
|
||||
switch (res) {
|
||||
case Success(_):
|
||||
return true;
|
||||
case Failure(e):
|
||||
this.handle.write(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,16 @@
|
||||
package kernel.binstore;
|
||||
|
||||
import bin.Service;
|
||||
import bin.LSPS;
|
||||
import bin.Turtle;
|
||||
import bin.Terminal;
|
||||
import haxe.ds.ReadOnlyArray;
|
||||
import bin.Redstone;
|
||||
import bin.Net;
|
||||
import bin.KernelLog;
|
||||
import bin.HelloWorld;
|
||||
import bin.GPS;
|
||||
import bin.Disk;
|
||||
import haxe.ds.ReadOnlyArray;
|
||||
|
||||
class BinStore {
|
||||
public static var instance: BinStore;
|
||||
@ -23,12 +24,13 @@ class BinStore {
|
||||
{c: Redstone, name: "Redstone", aliases: ["redstone","rs"]},
|
||||
{c: Terminal, name: "Terminal", aliases: ["terminal","term"]},
|
||||
{c: Turtle, name: "Turtle", aliases: ["turtle"]},
|
||||
{c: LSPS, name: "PM", aliases: ["lsps"]}
|
||||
{c: LSPS, name: "PM", aliases: ["lsps"]},
|
||||
{c: Service, name: "Service", aliases: ["service","srv"]}
|
||||
];
|
||||
|
||||
@:allow(kernel.Init)
|
||||
private function new() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getBinByName(name:String):Null<Bin> {
|
||||
|
Loading…
Reference in New Issue
Block a user