diff --git a/src/client/spark_api_server/Program.cs b/src/client/spark_api_server/Program.cs index 320541345..6689cd513 100644 --- a/src/client/spark_api_server/Program.cs +++ b/src/client/spark_api_server/Program.cs @@ -8,7 +8,6 @@ using System; using System.Reactive.Linq; - using System.Threading; using System.Threading.Tasks; class Program { @@ -26,7 +25,6 @@ static async Task _run(RunOptions opts) { Console.WriteLine("Starting spark_api_server... "); - var cancellationTokenSource = new CancellationTokenSource(); Log.notnull(opts.user); Log.notnull(opts.password); var service_ctx = ServiceContext.create(opts.sparkd); @@ -39,27 +37,14 @@ gwy.init(sync); sync.init(gwy); var errors = Errors.None; - var listen = Task.Run(async () => { - Log.Api.info("Starting websocket server..."); - try { - await gwy.start_listening(prms); - Log.Api.info("Websocket server stopped without error"); - } catch (Exception ex) { - Log.Api.error($"Websocket server threw ex: {ex}"); - errors |= Errors.Listen; - } - - }); - var task = Task.Run(() => { - while (!cancellationTokenSource.IsCancellationRequested) { - // Do something that can be interrupted - } - }, cancellationTokenSource.Token); - - Console.WriteLine("Press any key to stop the server..."); - Console.ReadKey(); - cancellationTokenSource.Cancel(); - await Task.WhenAny(task, listen); + Log.Api.info("Starting websocket server..."); + try { + await gwy.start_listening(prms); + Log.Api.info("Websocket server stopped without error"); + } catch (Exception ex) { + Log.Api.error($"Websocket server threw ex: {ex}"); + errors |= Errors.Listen; + } return (int)errors; } }