From b6530117f0dcc554114bfac8b86d9fb1fde605c4 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Thu, 28 Aug 2025 22:01:46 +0700 Subject: 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 "/". --- Makefile | 5 ++++- cmd/lilin/main.go | 6 +++--- 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 -- cgit v1.3