feat: add pidfile parameter to support OpenRC

This commit is contained in:
Hintay 2025-05-08 23:08:51 +09:00
parent c92b31e903
commit 6b40d02b93
No known key found for this signature in database
GPG key ID: 120FC7FF121F2F2D
7 changed files with 55 additions and 16 deletions

View file

@ -11,6 +11,7 @@ import (
"github.com/0xJacky/Nginx-UI/internal/cert"
"github.com/0xJacky/Nginx-UI/internal/cmd"
"github.com/0xJacky/Nginx-UI/internal/process"
"code.pfad.fr/risefront"
"github.com/0xJacky/Nginx-UI/internal/kernel"
@ -106,6 +107,14 @@ func main() {
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
defer cancel()
pidPath := appCmd.String("pidfile")
if pidPath != "" {
if err := process.WritePIDFile(pidPath); err != nil {
logger.Fatalf("Failed to write PID file: %v", err)
}
defer process.RemovePIDFile(pidPath)
}
err := risefront.New(ctx, risefront.Config{
Run: Program(ctx, confPath),
Name: "nginx-ui",