mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-24 03:06:48 +01:00
f3a03c4164
* fixes windows compilation, adds signal impl for windows, adds free space usage for windows, https://github.com/VictoriaMetrics/VictoriaMetrics/issues/70 https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1036 NOTE victoria metrics database still CANNOT work under windows system, only vmagent is supported. To completly port victoria metrics, you have to fix issues with separators, parsing and posix file removall * rollback separator * Adds windows setInformation api, it must behave like unix, need to test it. changes procutil * check for invlaid param * Fixes posix delete semantic * refactored a bit * fixes openbsd build * removed windows api call * Fixes code after windows add * Update lib/procutil/signal_windows.go Co-authored-by: Aliaksandr Valialkin <valyala@gmail.com>
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
// +build !windows
|
|
|
|
package procutil
|
|
|
|
import (
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
|
)
|
|
|
|
// WaitForSigterm waits for either SIGTERM or SIGINT
|
|
//
|
|
// Returns the caught signal.
|
|
//
|
|
// It also prevent from program termination on SIGHUP signal,
|
|
// since this signal is frequently used for config reloading.
|
|
func WaitForSigterm() os.Signal {
|
|
ch := make(chan os.Signal, 1)
|
|
signal.Notify(ch, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
|
|
for {
|
|
sig := <-ch
|
|
if sig == syscall.SIGHUP {
|
|
// Prevent from the program stop on SIGHUP
|
|
continue
|
|
}
|
|
return sig
|
|
}
|
|
}
|
|
|
|
// SelfSIGHUP sends SIGHUP signal to the current process.
|
|
func SelfSIGHUP() {
|
|
if err := syscall.Kill(syscall.Getpid(), syscall.SIGHUP); err != nil {
|
|
logger.Panicf("FATAL: cannot send SIGHUP to itself: %s", err)
|
|
}
|
|
}
|
|
|
|
// NewSighupChan returns a channel, which is triggered on every SIGHUP.
|
|
func NewSighupChan() <-chan os.Signal {
|
|
ch := make(chan os.Signal, 1)
|
|
signal.Notify(ch, syscall.SIGHUP)
|
|
return ch
|
|
}
|