Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option to keep trying and only stop when exit 0 #35

Closed
nbari opened this issue Dec 20, 2017 · 4 comments
Closed

option to keep trying and only stop when exit 0 #35

nbari opened this issue Dec 20, 2017 · 4 comments
Labels

Comments

@nbari
Copy link
Member

nbari commented Dec 20, 2017

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
Copy link
Member Author

nbari commented Dec 20, 2017

#32

probably option -r

@nbari
Copy link
Member Author

nbari commented Jan 4, 2018

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
Copy link
Member Author

nbari commented Jan 5, 2018

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
Copy link
Member Author

nbari commented Jan 10, 2018

fixed in 0.18.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant