Xing Xing 10 лет назад
Родитель
Сommit
09542d7176
1 измененных файлов: 10 добавлений и 7 удалений
  1. +10
    -7
      example/worker/worker.go

+ 10
- 7
example/worker/worker.go Просмотреть файл

@@ -7,6 +7,7 @@ import (
"os"
"strings"
"time"
"net"
)

func ToUpper(job worker.Job) ([]byte, error) {
@@ -39,13 +40,15 @@ func main() {
defer w.Close()
w.ErrorHandler = func(e error) {
log.Println(e)
if e == worker.ErrLostConn {
proc, err := os.FindProcess(os.Getpid())
if err != nil {
log.Println(err)
}
if err := proc.Signal(os.Interrupt); err != nil {
log.Println(err)
if opErr, ok := e.(*net.OpError); ok {
if ! opErr.Temporary() {
proc, err := os.FindProcess(os.Getpid())
if err != nil {
log.Println(err)
}
if err := proc.Signal(os.Interrupt); err != nil {
log.Println(err)
}
}
}
}


Загрузка…
Отмена
Сохранить