immortal/immortal

option to keep trying and only stop when exit 0

nbari opened this issue · 4 comments

nbari commented

In some cases, for example along rsync process would be nice to keep trying until X program exit 0:

immortal -l /tmp/rsync.log rsync -avz your-server.tld::maildirs /vmail/

once program exist successfully, immortal could exit

nbari commented

#32

probably option -r

nbari commented

currently testing with option -r and in the config with retries defaults to 0 which means unlimited

cmd: sleep 3
wait: 1
retries: 3

test using: immortal -c run.yml

nbari commented

Getting runtime error: invalid memory address or nil pointer dereference when sending exit signal and using immortaldir

The socket is created but the process is down or terminated, and when trying to get the pid the panic occurs:

  4 func (d *Daemon) HandleStatus(w http.ResponseWriter, r *http.Request) {
  3     status := Status{
  2         Cmd:   strings.Join(d.cfg.command, " "),
  1         Fpid:  d.fpid,
44          Pid:   d.process.Pid(),
  1         Count: atomic.LoadUint32(&d.count),
  2     }

panic output:

Jan  5 11:53:24 M20160001 immortal[32915]: http: panic serving : runtime error: invalid memory address or nil pointer dereference
        goroutine 18 [running]:
        net/http.(*conn).serve.func1(0xc420128000)
                /usr/local/Cellar/go/1.9.2/libexec/src/net/http/server.go:1697 +0xd0
        panic(0x12e5260, 0x14de060)
                /usr/local/Cellar/go/1.9.2/libexec/src/runtime/panic.go:491 +0x283
        github.com/immortal/immortal.(*process).Pid(...)
                /Users/nbari/projects/go/src/github.com/immortal/immortal/process.go:158
        github.com/immortal/immortal.(*Daemon).HandleStatus(0xc4200606c0, 0x14b4920, 0xc42013a000, 0xc420130000)
                /Users/nbari/projects/go/src/github.com/immortal/immortal/socket.go:44 +0x90
        github.com/immortal/immortal.(*Daemon).HandleStatus-fm(0x14b4920, 0xc42013a000, 0xc420130000)
                /Users/nbari/projects/go/src/github.com/immortal/immortal/socket.go:33 +0x48
        net/http.HandlerFunc.ServeHTTP(0xc420042cb0, 0x14b4920, 0xc42013a000, 0xc420130000)
                /usr/local/Cellar/go/1.9.2/libexec/src/net/http/server.go:1918 +0x44
        github.com/nbari/violetear.(*Router).ServeHTTP(0xc4200f9110, 0x14b4920, 0xc42013a000, 0xc420130000)
                /Users/nbari/projects/go/src/github.com/nbari/violetear/violetear.go:285 +0x43c
        net/http.serverHandler.ServeHTTP(0xc420112000, 0x14b4920, 0xc42013a000, 0xc420130000)
                /usr/local/Cellar/go/1.9.2/libexec/src/net/http/server.go:2619 +0xb4
        net/http.(*conn).serve(0xc420128000, 0x14b4e60, 0xc420116100)
                /usr/local/Cellar/go/1.9.2/libexec/src/net/http/server.go:1801 +0x71d
        created by net/http.(*Server).Serve
                /usr/local/Cellar/go/1.9.2/libexec/src/net/http/server.go:2720 +0x288

This happens wuen using wait, there will be no process after X ammount of time:

Jan  5 12:59:32 M20160001 immortal[65951]: runtime error: invalid memory address or nil pointer dereference
Jan  5 12:59:32 M20160001 immortal[65951]: d = &{cfg:0xc4200b0500 count:1 lock:1 lockOnce:0 fpid:false process:<nil> quit:0xc420078120 

So need to check if the process exists before trying to get the PID.

nbari commented

fixed in 0.18.0