mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-05-03 06:22:56 +03:00
Pull request: home: imp err handling, marshalling
Merge in DNS/adguard-home from imp-code to master Squashed commit of the following: commit 9433fb9b0154a1cfaf804edbfa8531efbbcbf68a Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Fri May 14 19:24:32 2021 +0300 home: imp err handling, marshalling
This commit is contained in:
parent
9d788a2983
commit
a031cae447
6 changed files with 56 additions and 63 deletions
internal/home
|
@ -1,6 +1,7 @@
|
|||
package home
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
@ -88,24 +89,27 @@ func svcAction(s service.Service, action string) (err error) {
|
|||
// If pid-file doesn't exist, find our PID using 'ps' command
|
||||
func sendSigReload() {
|
||||
if runtime.GOOS == "windows" {
|
||||
log.Error("Not implemented on Windows")
|
||||
log.Error("not implemented on windows")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
pidfile := fmt.Sprintf("/var/run/%s.pid", serviceName)
|
||||
data, err := ioutil.ReadFile(pidfile)
|
||||
if os.IsNotExist(err) {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
var code int
|
||||
var psdata string
|
||||
code, psdata, err = aghos.RunCommand("ps", "-C", serviceName, "-o", "pid=")
|
||||
if err != nil || code != 0 {
|
||||
log.Error("Can't find AdGuardHome process: %s code:%d", err, code)
|
||||
log.Error("finding AdGuardHome process: code: %d, error: %s", code, err)
|
||||
|
||||
return
|
||||
}
|
||||
data = []byte(psdata)
|
||||
|
||||
data = []byte(psdata)
|
||||
} else if err != nil {
|
||||
log.Error("Can't read PID file %s: %s", pidfile, err)
|
||||
log.Error("reading pid file %s: %s", pidfile, err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -258,12 +262,12 @@ func handleServiceUninstallCommand(s service.Service) {
|
|||
if runtime.GOOS == "darwin" {
|
||||
// Remove log files on cleanup and log errors.
|
||||
err = os.Remove(launchdStdoutPath)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
log.Printf("removing stdout file: %s", err)
|
||||
}
|
||||
|
||||
err = os.Remove(launchdStderrPath)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
log.Printf("removing stderr file: %s", err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue