File tree 2 files changed +18
-11
lines changed
2 files changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ func readProcfile() error {
66
66
func readEnvfile () error {
67
67
content , err := ioutil .ReadFile (".env" )
68
68
if err != nil {
69
- if os .IsNotExist (err ){
69
+ if os .IsNotExist (err ) {
70
70
return nil
71
71
}
72
72
return err
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
+ "errors"
4
5
"os"
5
6
"os/signal"
6
7
"sync"
@@ -16,7 +17,12 @@ func stopProc(proc string, quit bool) error {
16
17
}
17
18
18
19
procs [proc ].quit = quit
19
- return procs [proc ].cmd .Process .Signal (syscall .SIGINT )
20
+ err := procs [proc ].cmd .Process .Signal (syscall .SIGINT )
21
+ if err != nil {
22
+ return err
23
+ }
24
+ _ , err = procs [proc ].cmd .Process .Wait ()
25
+ return err
20
26
}
21
27
22
28
func done () {
@@ -48,7 +54,12 @@ func restartProc(proc string) error {
48
54
if err != nil {
49
55
return err
50
56
}
51
- return startProc (proc )
57
+ println ("spawn" )
58
+ if ! spawnProc (proc ) {
59
+ return errors .New ("Failed to restart" )
60
+ }
61
+ println ("spawned" )
62
+ return nil
52
63
}
53
64
54
65
// spawn all procs.
@@ -66,15 +77,11 @@ func startProcs() error {
66
77
}()
67
78
signal .Notify (sc , syscall .SIGTERM , syscall .SIGINT , syscall .SIGHUP )
68
79
<- sc
69
- if state {
70
- for proc , p := range procs {
71
- if p .cmd != nil {
72
- stopProc (proc , true )
73
- } else {
74
- done ()
75
- }
80
+ for proc , p := range procs {
81
+ if p .cmd != nil {
82
+ stopProc (proc , true )
76
83
}
84
+ done ()
77
85
}
78
- wg .Wait ()
79
86
return nil
80
87
}
You can’t perform that action at this time.
0 commit comments