-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build and run (VOD only) on Windows systems.
Really the only platform-dependent bits of code were the process group management. I've replaced those with Windows-specific versions, although I haven't fully tested them, because I'm not entirely sure how they're used. Also, the build configuration for Linux and other non-Windows platforms is completely untested.
- Loading branch information
1 parent
476d93b
commit d40cdf0
Showing
6 changed files
with
75 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
/go-transcode | ||
/bin | ||
/.env | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package hls | ||
|
||
import "syscall" | ||
|
||
func ConfigureAsProcessGroup() *syscall.SysProcAttr { | ||
return &syscall.SysProcAttr{Setpgid: true} | ||
} | ||
|
||
func (m *ManagerCtx) Stop() { | ||
m.mu.Lock() | ||
defer m.mu.Unlock() | ||
|
||
if m.cmd != nil && m.cmd.Process != nil { | ||
m.logger.Debug().Msg("performing stop") | ||
|
||
pgid, err := syscall.Getpgid(m.cmd.Process.Pid) | ||
if err == nil { | ||
err := syscall.Kill(-pgid, syscall.SIGKILL) | ||
m.logger.Err(err).Msg("killing process group") | ||
} else { | ||
m.logger.Err(err).Msg("could not get process group id") | ||
err := m.cmd.Process.Kill() | ||
m.logger.Err(err).Msg("killing process") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package hls | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"strconv" | ||
"syscall" | ||
) | ||
|
||
func ConfigureAsProcessGroup() *syscall.SysProcAttr { | ||
return &syscall.SysProcAttr{CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP} | ||
} | ||
|
||
func TaskkillWithChildrenWindows(cmd *exec.Cmd) error { | ||
// Function adopted from: https://stackoverflow.com/a/44551450/6278 | ||
// Taskkill command documentation: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill | ||
|
||
kill := exec.Command("TASKKILL", "/T", "/PID", strconv.Itoa(cmd.Process.Pid)) | ||
kill.Stderr = os.Stderr | ||
kill.Stdout = os.Stdout | ||
return kill.Run() | ||
} | ||
|
||
func (m *ManagerCtx) Stop() { | ||
m.mu.Lock() | ||
defer m.mu.Unlock() | ||
|
||
if m.cmd != nil && m.cmd.Process != nil { | ||
m.logger.Debug().Msg("performing stop") | ||
|
||
err := TaskkillWithChildrenWindows(m.cmd) | ||
if err == nil { | ||
m.logger.Debug().Msg("killing process group") | ||
} else { | ||
m.logger.Err(err).Msg("failed to kill process group") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters