MCPcopy Index your code
hub / github.com/coder/envbox / Restart

Method Restart

background/process.go:84–102  ·  view source on GitHub ↗

Restart kill the running process and reruns the command with the updated cmd and args.

(ctx context.Context, cmd string, args ...string)

Source from the content-addressed store, hash-verified

82// Restart kill the running process and reruns the command with the updated
83// cmd and args.
84func (d *Process) Restart(ctx context.Context, cmd string, args ...string) error {
85 d.mu.Lock()
86 defer d.mu.Unlock()
87
88 err := d.kill(syscall.SIGTERM)
89 if err != nil {
90 return xerrors.Errorf("kill cmd: %w", err)
91 }
92
93 ctx, cancel := context.WithCancel(ctx)
94 d.ctx = ctx
95 d.cancel = cancel
96 d.cmd = xunix.GetExecer(ctx).CommandContext(ctx, cmd, args...)
97 d.waitCh = make(chan error, 1)
98 d.userKilled = i64ptr(0)
99 d.binName = cmd
100
101 return d.startProcess()
102}
103
104func (d *Process) startProcess() error {
105 var (

Callers 1

dockerCmdFunction · 0.80

Calls 6

killMethod · 0.95
startProcessMethod · 0.95
GetExecerFunction · 0.92
i64ptrFunction · 0.85
ErrorfMethod · 0.65
CommandContextMethod · 0.65

Tested by

no test coverage detected