Skip to content

Commit 2045363

Browse files
authored
Don't kill exec process immediately (#484)
1 parent 18760d2 commit 2045363

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

cmd/litestream/main.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,17 @@ func (m *Main) Run(ctx context.Context, args []string) (err error) {
8686
}
8787

8888
// Setup signal handler.
89-
ctx, cancel := context.WithCancel(ctx)
9089
signalCh := signalChan()
9190

92-
if err := c.Run(ctx); err != nil {
91+
if err := c.Run(); err != nil {
9392
return err
9493
}
9594

9695
// Wait for signal to stop program.
9796
select {
9897
case err = <-c.execCh:
99-
cancel()
10098
fmt.Println("subprocess exited, litestream shutting down")
10199
case sig := <-signalCh:
102-
cancel()
103100
fmt.Println("signal received, litestream shutting down")
104101

105102
if c.cmd != nil {

cmd/litestream/replicate.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (c *ReplicateCommand) ParseFlags(ctx context.Context, args []string) (err e
9494
}
9595

9696
// Run loads all databases specified in the configuration.
97-
func (c *ReplicateCommand) Run(ctx context.Context) (err error) {
97+
func (c *ReplicateCommand) Run() (err error) {
9898
// Display version information.
9999
log.Printf("litestream %s", Version)
100100

@@ -162,7 +162,7 @@ func (c *ReplicateCommand) Run(ctx context.Context) (err error) {
162162
return fmt.Errorf("cannot parse exec command: %w", err)
163163
}
164164

165-
c.cmd = exec.CommandContext(ctx, execArgs[0], execArgs[1:]...)
165+
c.cmd = exec.Command(execArgs[0], execArgs[1:]...)
166166
c.cmd.Env = os.Environ()
167167
c.cmd.Stdout = os.Stdout
168168
c.cmd.Stderr = os.Stderr

0 commit comments

Comments
 (0)