aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2025-08-28 22:01:46 +0700
committerShulhan <ms@kilabit.info>2025-08-28 22:01:46 +0700
commitb6530117f0dcc554114bfac8b86d9fb1fde605c4 (patch)
tree27d51fb2fbf6fb649099606625f39d7fd0fee5e0
parent4e309ddeaebb06512ddb1473ec2207b4ad2c0a0b (diff)
downloadlilin-b6530117f0dcc554114bfac8b86d9fb1fde605c4.tar.xz
cmd/lilin: add flag to set basedir
The basedir flag set the working directory where the program will read the configuration and store the logs. By default the basedir is empty, which is equal to "/".
-rw-r--r--Makefile5
-rw-r--r--cmd/lilin/main.go6
2 files changed, 7 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index fda06e4..56bbe5b 100644
--- a/Makefile
+++ b/Makefile
@@ -20,4 +20,7 @@ test:
.PHONY: dev.test
dev.test:
- go run ./cmd/lilin -dev
+ truncate --size=0 testdata/var/log/lilin/service.d/http.log
+ truncate --size=0 testdata/var/log/lilin/service.d/tcp.log
+ truncate --size=0 testdata/var/log/lilin/service.d/udp.log
+ go run ./cmd/lilin -dev -basedir=testdata/
diff --git a/cmd/lilin/main.go b/cmd/lilin/main.go
index 70d68d0..874c9cd 100644
--- a/cmd/lilin/main.go
+++ b/cmd/lilin/main.go
@@ -15,12 +15,12 @@ import (
)
func main() {
- var serverCfg = lilin.ServerConfig{
- BaseDir: `testdata`,
- }
+ var serverCfg = lilin.ServerConfig{}
flag.BoolVar(&serverCfg.IsDevelopment, `dev`, false,
`Enable development mode`)
+ flag.StringVar(&serverCfg.BaseDir, `basedir`, ``,
+ `Set the base directory`)
flag.Parse()
var server *lilin.Server