bamzi / jobrunner

Framework for performing work asynchronously, outside of the request flow
MIT License
1.04k stars 99 forks source link

Job runner quits after start #2

Closed exu closed 8 years ago

exu commented 8 years ago

I'm trying to run jobrunner but it quits right after start:

package main

import (
    "fmt"
    "github.com/bamzi/jobrunner"
)

func main() {
    jobrunner.Start(10, 1)
    jobrunner.Schedule("@every 5s", ReminderEmails{})
}

type ReminderEmails struct {
}

func (e ReminderEmails) Run() {
    fmt.Printf("Every 5 sec send reminder emails \n")
}

Output:

❯ go run app.go
[JobRunner] 2015/10/30 - 09:48:06 Started...  

❯ 

Go version

go version go1.5.1 linux/amd64
alehano commented 8 years ago

Your program exited. Try to add for {} at the end of main.

exu commented 8 years ago

ok working thanks :)

bamzi commented 8 years ago

@alehano Thank you for helping

@exu If you don't intend to use a http server session then you need to keep the app running with {} or select {} at the end of the func main() {...}.

However, the problem is, if any crash happens mid process (i.e. at 3am) then everything is stopped and you cannot recover unless you manually restart the app.