mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-11-03 09:51:26 +08:00
cleanup
This commit is contained in:
@@ -8,14 +8,14 @@ const (
|
||||
retryPause = 5 * time.Second
|
||||
)
|
||||
|
||||
// Environment is a ExternalCmd environment.
|
||||
// Environment is a Cmd environment.
|
||||
type Environment struct {
|
||||
Path string
|
||||
Port string
|
||||
}
|
||||
|
||||
// ExternalCmd is an external command.
|
||||
type ExternalCmd struct {
|
||||
// Cmd is an external command.
|
||||
type Cmd struct {
|
||||
cmdstr string
|
||||
restart bool
|
||||
env Environment
|
||||
@@ -27,9 +27,9 @@ type ExternalCmd struct {
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
// New allocates an ExternalCmd.
|
||||
func New(cmdstr string, restart bool, env Environment) *ExternalCmd {
|
||||
e := &ExternalCmd{
|
||||
// New allocates an Cmd.
|
||||
func New(cmdstr string, restart bool, env Environment) *Cmd {
|
||||
e := &Cmd{
|
||||
cmdstr: cmdstr,
|
||||
restart: restart,
|
||||
env: env,
|
||||
@@ -41,13 +41,13 @@ func New(cmdstr string, restart bool, env Environment) *ExternalCmd {
|
||||
return e
|
||||
}
|
||||
|
||||
// Close closes an ExternalCmd.
|
||||
func (e *ExternalCmd) Close() {
|
||||
// Close closes an Cmd.
|
||||
func (e *Cmd) Close() {
|
||||
close(e.terminate)
|
||||
<-e.done
|
||||
}
|
||||
|
||||
func (e *ExternalCmd) run() {
|
||||
func (e *Cmd) run() {
|
||||
defer close(e.done)
|
||||
|
||||
for {
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func (e *ExternalCmd) runInner() bool {
|
||||
func (e *Cmd) runInner() bool {
|
||||
cmd := exec.Command("/bin/sh", "-c", "exec "+e.cmdstr)
|
||||
|
||||
cmd.Env = append(os.Environ(),
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/kballard/go-shellquote"
|
||||
)
|
||||
|
||||
func (e *ExternalCmd) runInner() bool {
|
||||
func (e *Cmd) runInner() bool {
|
||||
// on Windows the shell is not used and command is started directly
|
||||
// variables are replaced manually in order to guarantee compatibility
|
||||
// with Linux commands
|
||||
@@ -155,7 +155,7 @@ type Path struct {
|
||||
sourceTrackCount int
|
||||
sourceSdp []byte
|
||||
readers *readersMap
|
||||
onDemandCmd *externalcmd.ExternalCmd
|
||||
onDemandCmd *externalcmd.Cmd
|
||||
describeTimer *time.Timer
|
||||
sourceCloseTimer *time.Timer
|
||||
sourceCloseTimerStarted bool
|
||||
@@ -244,7 +244,7 @@ func (pa *Path) run() {
|
||||
pa.startExternalSource()
|
||||
}
|
||||
|
||||
var onInitCmd *externalcmd.ExternalCmd
|
||||
var onInitCmd *externalcmd.Cmd
|
||||
if pa.conf.RunOnInit != "" {
|
||||
pa.Log("on init command started")
|
||||
onInitCmd = externalcmd.New(pa.conf.RunOnInit, pa.conf.RunOnInitRestart, externalcmd.Environment{
|
||||
|
||||
Reference in New Issue
Block a user