Pull request 1879: nextapi-opts
Merge in DNS/adguard-home from nextapi-opts to master
Squashed commit of the following:
commit 01f27e374785f47f41470126ddc17cf447e84dd7
Merge: 17d3b06e0 371261b2c
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Tue Jun 20 13:43:08 2023 +0300
Merge branch 'master' into nextapi-opts
commit 17d3b06e0551908b06be67233181ce4067b6c1cc
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Tue Jun 20 13:15:31 2023 +0300
next: imp chlog
commit 19d5ea9db0ee077c55c9f1d54a07a3c6b56b4e2e
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Tue Jun 20 12:58:48 2023 +0300
cmd: typo
commit 082ad5b5fc634a1533127e428680ccf55c0811ab
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon Jun 19 22:49:16 2023 +0300
cmd: imp api, docs, names
commit a49b3cbcc591f36530306c2e08cf1ea7dc8f6d30
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon Jun 19 17:13:50 2023 +0300
next/cmd: add opt parsing
This commit is contained in:
@@ -17,20 +17,31 @@ import (
|
||||
|
||||
// Main is the entry point of AdGuard Home.
|
||||
func Main(frontend fs.FS) {
|
||||
// Initial Configuration
|
||||
|
||||
start := time.Now()
|
||||
|
||||
// TODO(a.garipov): Set up logging.
|
||||
// Initial Configuration
|
||||
|
||||
cmdName := os.Args[0]
|
||||
opts, err := parseOptions(cmdName, os.Args[1:])
|
||||
exitCode, needExit := processOptions(opts, cmdName, err)
|
||||
if needExit {
|
||||
os.Exit(exitCode)
|
||||
}
|
||||
|
||||
err = setLog(opts)
|
||||
check(err)
|
||||
|
||||
log.Info("starting adguard home, version %s, pid %d", version.Version(), os.Getpid())
|
||||
|
||||
if opts.workDir != "" {
|
||||
log.Info("changing working directory to %q", opts.workDir)
|
||||
err = os.Chdir(opts.workDir)
|
||||
check(err)
|
||||
}
|
||||
|
||||
// Web Service
|
||||
|
||||
// TODO(a.garipov): Set up configuration file name.
|
||||
const confFile = "AdGuardHome.1.yaml"
|
||||
|
||||
confMgr, err := configmgr.New(confFile, frontend, start)
|
||||
confMgr, err := configmgr.New(opts.confFile, frontend, start)
|
||||
check(err)
|
||||
|
||||
web := confMgr.Web()
|
||||
@@ -42,7 +53,7 @@ func Main(frontend fs.FS) {
|
||||
check(err)
|
||||
|
||||
sigHdlr := newSignalHandler(
|
||||
confFile,
|
||||
opts.confFile,
|
||||
frontend,
|
||||
start,
|
||||
web,
|
||||
|
||||
Reference in New Issue
Block a user