server

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPort = 2026

Variables

This section is empty.

Functions

func EnsurePortIsFree

func EnsurePortIsFree(port int, log logger.Logger)

EnsurePortIsFree prüft, ob der Port frei ist. Falls nicht, wird der Prozess per Port-Suche gekillt und gewartet, bis der Port frei ist.

func GracefulShutdown

func GracefulShutdown(server *http.Server, pidFile string, log logger.Logger)

GracefulShutdown wartet immer selbst auf SIGTERM/SIGINT und loggt das Signal.

func IsPortBusy

func IsPortBusy(port int) (bool, int, error)

IsPortBusy prüft, ob der Port bereits belegt ist. Gibt ggf. die PID des Prozesses zurück (immer 0, da Go das nicht nativ unterstützt).

func LogFileName

func LogFileName(prefix string) string

LogFileName returns a log file name based on the current datetime (YYYYMMDD_HHMMSS.log)

func ReadPID

func ReadPID(pidFile string) (int, error)

ReadPID reads the PID from the specified file

func RemovePID

func RemovePID(pidFile string) error

RemovePID removes the PID file

func SendSIGTERM

func SendSIGTERM(pid int) error

func SetSecurityLayer added in v0.1.4

func SetSecurityLayer(layer security.SecurityLayer)

Add a setter for the security layer

func ShutdownServer

func ShutdownServer(configPath string, log logger.Logger) error

func WaitForPortFreed

func WaitForPortFreed(port int, log logger.Logger)

WaitForPortFreed wartet, bis der Port nicht mehr belegt ist (Timeout: 10s)

func WritePID

func WritePID(pidFile string) error

WritePID writes the current process PID to the specified file

Types

type Config

type Config struct {
	Port        int      `json:"port"`
	PidFile     string   `json:"pid_file"`
	DomainFiles []string `json:"domain_files,omitempty"`
}

func LoadConfig

func LoadConfig(path string) (*Config, error)

func StartServer

func StartServer(configPath string, log logger.Logger) (*http.Server, *Config, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL