mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
disable win sleep
This commit is contained in:
@@ -1,7 +1,28 @@
|
|||||||
|
//go:build windows
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
func Preconfig(kill bool) {
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
EsSystemRequired = 0x00000001
|
||||||
|
EsContinuous = 0x80000000
|
||||||
|
)
|
||||||
|
|
||||||
|
var pulseTime = 1 * time.Minute
|
||||||
|
|
||||||
|
func Preconfig(kill bool) {
|
||||||
|
// don't sleep/hibernate windows
|
||||||
|
kernel32 := syscall.NewLazyDLL("kernel32.dll")
|
||||||
|
setThreadExecStateProc := kernel32.NewProc("SetThreadExecutionState")
|
||||||
|
pulse := time.NewTicker(pulseTime)
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-pulse.C:
|
||||||
|
setThreadExecStateProc.Call(uintptr(EsSystemRequired))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user