diff --git a/src/Neo.CLI/CLI/MainService.cs b/src/Neo.CLI/CLI/MainService.cs index 4b0fccb343..b8d52a6a02 100644 --- a/src/Neo.CLI/CLI/MainService.cs +++ b/src/Neo.CLI/CLI/MainService.cs @@ -346,11 +346,10 @@ private byte[] LoadUpdateScript(UInt160 scriptHash, string nefFilePath, string m } } - public override void OnStart(string[] args) + public override bool OnStart(string[] args) { - base.OnStart(args); - OnStartWithCommandLine(args); - + if (!base.OnStart(args)) return false; + return OnStartWithCommandLine(args) != 1; } public override void OnStop() diff --git a/src/Neo.ConsoleService/ConsoleServiceBase.cs b/src/Neo.ConsoleService/ConsoleServiceBase.cs index 8b169fb808..1da87354fb 100644 --- a/src/Neo.ConsoleService/ConsoleServiceBase.cs +++ b/src/Neo.ConsoleService/ConsoleServiceBase.cs @@ -283,12 +283,13 @@ protected void OnExit() #endregion - public virtual void OnStart(string[] args) + public virtual bool OnStart(string[] args) { // Register sigterm event handler AssemblyLoadContext.Default.Unloading += SigTermEventHandler; // Register sigint event handler Console.CancelKeyPress += CancelHandler; + return true; } public virtual void OnStop() @@ -428,7 +429,7 @@ public void Run(string[] args) { if (Environment.UserInteractive) { - if (args.Length > 0 && args[0] == "/install") + if (args.Length == 1 && args[0] == "/install") { if (Environment.OSVersion.Platform != PlatformID.Win32NT) { @@ -457,7 +458,7 @@ public void Run(string[] args) Console.Write(process.StandardOutput.ReadToEnd()); } } - else if (args.Length > 0 && args[0] == "/uninstall") + else if (args.Length == 1 && args[0] == "/uninstall") { if (Environment.OSVersion.Platform != PlatformID.Win32NT) { @@ -483,8 +484,7 @@ public void Run(string[] args) } else { - OnStart(args); - RunConsole(); + if (OnStart(args)) RunConsole(); OnStop(); } }