aboutsummaryrefslogtreecommitdiff
path: root/server_options.go
diff options
context:
space:
mode:
Diffstat (limited to 'server_options.go')
-rw-r--r--server_options.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/server_options.go b/server_options.go
index 4a033fc..48c47b6 100644
--- a/server_options.go
+++ b/server_options.go
@@ -22,6 +22,12 @@ type ServerOptions struct {
// The BaseDir + "/etc/lilin/".
configDir string
+ // The BaseDir + "/etc/lilin/service.d/".
+ configServiceDir string
+
+ // The BaseDir + "/var/log/lilin/service.d/".
+ logServiceDir string
+
// The address to listen for HTTP server and APIs.
Address string `ini:"server::address"`
@@ -40,6 +46,15 @@ func (opts *ServerOptions) init() (err error) {
}
opts.configDir = filepath.Join(opts.BaseDir, `etc`, `lilin`)
+ opts.configServiceDir = filepath.Join(opts.configDir, `service.d`)
+ opts.logServiceDir = filepath.Join(opts.BaseDir, `var`, `log`, `lilin`, `service.d`)
+
+ err = os.MkdirAll(opts.logServiceDir, 0700)
+ if err != nil {
+ return fmt.Errorf(`%s: %w`, logp, err)
+ }
+
+ // Load main configuration.
var cfg = filepath.Join(opts.configDir, `lilin.cfg`)
_, err = os.Stat(cfg)
@@ -57,8 +72,8 @@ func (opts *ServerOptions) init() (err error) {
return fmt.Errorf(`%s: %w`, logp, err)
}
- if opts.Address == "" {
- return fmt.Errorf(`%s: empty Address`, logp)
+ if opts.Address == `` {
+ opts.Address = defAddress
}
return nil