From cf087fb8ff251e1680b1bf8ee7ca4d4905dfbbc5 Mon Sep 17 00:00:00 2001
From: Simon Zolin <s.zolin@adguard.com>
Date: Thu, 11 Jun 2020 10:24:43 +0300
Subject: [PATCH] - service: "stop" didn't work correctly Close #1785

Squashed commit of the following:

commit 40eba3049ac339b4e2537b2fd598c2fb1c6e8cd0
Author: Simon Zolin <s.zolin@adguard.com>
Date:   Wed Jun 10 19:43:14 2020 +0300

    - service: "stop" didn't work correctly
---
 home/home.go | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/home/home.go b/home/home.go
index f4028b89..e93daa60 100644
--- a/home/home.go
+++ b/home/home.go
@@ -110,11 +110,6 @@ func Main(version string, channel string, armVer string) {
 	// therefore, we must do it manually instead of using a lib
 	args := loadOptions()
 
-	if args.serviceControlAction != "" {
-		handleServiceControlAction(args.serviceControlAction)
-		return
-	}
-
 	Context.appSignalChannel = make(chan os.Signal)
 	signal.Notify(Context.appSignalChannel, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT)
 	go func() {
@@ -134,6 +129,11 @@ func Main(version string, channel string, armVer string) {
 		}
 	}()
 
+	if args.serviceControlAction != "" {
+		handleServiceControlAction(args.serviceControlAction)
+		return
+	}
+
 	// run the protection
 	run(args)
 }