Skip to content

BAIGUANGMEI/goser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GoSer - Go Service Manager

GoSer Logo

A non-blocking service manager for Windows, built with Go.
Similar to Linux's systemd, GoSer manages background processes with a modern GUI and CLI.

Dashboard β€’ Features β€’ Quick Start β€’ CLI β€’ GUI β€’ API β€’ License


Dashboard

dashboard

Features

  • Process Management β€” Start, stop, restart, and monitor background services
  • Auto-restart β€” Configurable restart on failure with max retry limits
  • YAML Configuration β€” Simple per-service YAML config files
  • Modern GUI β€” Desktop application built with Wails + Vue 3 + TailwindCSS
  • CLI β€” Full-featured command-line interface
  • Real-time Logs β€” View output with WebSocket streaming, content-based error highlighting
  • Service Dependencies β€” Topological ordering via depends_on
  • Windows Service β€” Can run as a native Windows service
  • Health Checks β€” HTTP, TCP, and command-based health checks
  • Process Tree Management β€” Reliable process tree termination using Windows Job Objects

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   GoSer CLI     β”‚    β”‚  GoSer GUI App  β”‚
β”‚  (goser.exe)    β”‚    β”‚ (goser-app.exe) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚   HTTP REST + WS    β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚   GoSer Daemon      β”‚
         β”‚   (goserd.exe)      β”‚
         β”‚                     β”‚
         β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
         β”‚  β”‚Process Managerβ”‚  β”‚
         β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
         β”‚          β”‚          β”‚
         β”‚  β”Œβ”€β”€β”€β” β”Œβ”€β”€β”€β” β”Œβ”€β”€β”€β” β”‚
         β”‚  β”‚Svcβ”‚ β”‚Svcβ”‚ β”‚Svcβ”‚ β”‚
         β”‚  β”‚ A β”‚ β”‚ B β”‚ β”‚ C β”‚ β”‚
         β”‚  β””β”€β”€β”€β”˜ β””β”€β”€β”€β”˜ β””β”€β”€β”€β”˜ β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Quick Start

Prerequisites

  • Go 1.21+
  • Node.js 18+
  • Inno Setup 6 (optional, for installer)

Build

# Build all binaries (daemon, CLI, GUI)
.\build\build.ps1

# Build with installer
.\build\build.ps1 -Installer

Or build individually:

# Frontend
cd cmd/app/frontend && npm install && npx vite build && cd ../../..

# Daemon
go build -ldflags="-s -w" -o dist/goserd.exe ./cmd/goserd

# CLI
go build -ldflags="-s -w" -o dist/goser.exe ./cmd/goser

# GUI (requires Wails build tags)
go build -tags "desktop,production" -ldflags="-s -w -H=windowsgui" -o dist/goser-app.exe ./cmd/app

Start the Daemon

goserd.exe
# or via CLI
goser daemon start

Add a Service

Create a YAML config file:

name: my-web-app
command: node
args:
  - server.js
working_dir: "C:/projects/my-app"
env:
  NODE_ENV: production
  PORT: "3000"
auto_start: true
auto_restart: true
max_restarts: 5
restart_delay: 5s
goser add my-service.yaml
goser start my-web-app

Monitor

goser list                  # List all services
goser status my-web-app     # Detailed status
goser logs my-web-app       # View logs

Launch GUI

goser-app.exe

CLI Reference

goser daemon start          Start the daemon in background
goser daemon stop           Stop the daemon
goser daemon status         Check daemon status

goser list                  List all services with status
goser start <name>          Start a service
goser stop <name>           Stop a service
goser restart <name>        Restart a service
goser status <name>         Detailed service status

goser add <yaml-file>       Add a service from YAML file
goser remove <name>         Remove a service
goser enable <name>         Enable auto-start
goser disable <name>        Disable auto-start

goser logs <name>           View recent logs
goser logs -n 100 <name>    View last 100 lines

GUI

The GUI provides a modern interface with:

  • Dashboard β€” Overview of service statistics and daemon status
  • Services β€” List, search, filter, create, edit, and manage services
  • Logs β€” Real-time log streaming with content-based error highlighting
  • Settings β€” Configure daemon connection
  • Daemon Control β€” Start/stop daemon directly from the sidebar

Service Configuration

Service files are stored in ~/.goser/services/<name>.yaml:

name: my-service            # Required: unique service name
command: node               # Required: executable to run
args:                       # Optional: command arguments
  - server.js
  - --port=3000
working_dir: "C:/myapp"    # Optional: working directory
env:                        # Optional: environment variables
  NODE_ENV: production
auto_start: true            # Start when daemon starts
auto_restart: true          # Restart on failure
max_restarts: 5             # Max restart attempts
restart_delay: 5s           # Delay between restarts
stop_timeout: 10s           # Force kill timeout
depends_on:                 # Optional: service dependencies
  - database
health_check:               # Optional: health monitoring
  type: http
  endpoint: "http://localhost:3000/health"
  interval: 30s
  timeout: 5s

Global Configuration

Located at ~/.goser/config.yaml:

daemon:
  listen: "127.0.0.1:9876"
  log_dir: "~/.goser/logs"
  pid_file: "~/.goser/goserd.pid"
  max_log_size: "50MB"
  log_retention: 7

Windows Service

Install as a Windows service for auto-start on boot:

# Install (run as Administrator)
goserd.exe -install

# Start via Windows services
sc start GoSerDaemon

# Uninstall
goserd.exe -uninstall

REST API

The daemon exposes a REST API on 127.0.0.1:9876:

Method Endpoint Description
GET /api/daemon/status Daemon health
GET /api/services List all services
GET /api/services/:name Get service detail
POST /api/services Create service
PUT /api/services/:name Update service
DELETE /api/services/:name Remove service
POST /api/services/:name/start Start service
POST /api/services/:name/stop Stop service
POST /api/services/:name/restart Restart service
GET /api/services/:name/logs Get service logs
WS /ws Real-time events

Tech Stack

Project Structure

goser/
β”œβ”€β”€ cmd/
β”‚   β”œβ”€β”€ goserd/              # Daemon entry point
β”‚   β”œβ”€β”€ goser/               # CLI entry point
β”‚   └── app/                 # Wails GUI entry point
β”‚       └── frontend/        # Vue 3 + TypeScript frontend
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ daemon/              # HTTP server & API handlers
β”‚   β”œβ”€β”€ manager/             # Process manager core
β”‚   β”‚   β”œβ”€β”€ process.go       # Single process lifecycle
β”‚   β”‚   β”œβ”€β”€ manager.go       # Service orchestration
β”‚   β”‚   β”œβ”€β”€ monitor.go       # Auto-restart monitor
β”‚   β”‚   └── procutil_*.go    # Platform-specific process utils
β”‚   β”œβ”€β”€ client/              # HTTP client library
β”‚   β”œβ”€β”€ config/              # Configuration models & loader
β”‚   β”œβ”€β”€ model/               # Shared data types
β”‚   └── logger/              # Logging & log collection
β”œβ”€β”€ build/
β”‚   β”œβ”€β”€ build.ps1            # Windows build script
β”‚   β”œβ”€β”€ windows/             # Installer & icons
β”‚   └── icongen/             # ICO generation utility
β”œβ”€β”€ go.mod
β”œβ”€β”€ Makefile
└── wails.json

License

MIT

About

A lightweight non-blocking service manager for Windows

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors