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

Worker dies after 1 request (cant use as a daemon) #52

Open
ergoz opened this issue Oct 1, 2014 · 3 comments
Open

Worker dies after 1 request (cant use as a daemon) #52

ergoz opened this issue Oct 1, 2014 · 3 comments

Comments

@ergoz
Copy link

ergoz commented Oct 1, 2014

Example code

package main

import
(
    "github.com/mikespook/gearman-go/worker"
    "log"
)

func ToUpper(job worker.Job) ([]byte, error) {
    log.Printf("ToUpper: Data=[%s]\n", job.Data())
    job.SendData(job.Data())
    job.UpdateStatus(1, 1)
    return nil, nil
}

func main() {
    log.Println("Starting ...")
    defer log.Println("Shutdown complete!")

    w := worker.New( worker.Unlimited )
    defer w.Close()

    w.ErrorHandler = func(e error) {
        log.Fatal(e)
        return
    }

    w.JobHandler = func(job worker.Job) error {
        log.Printf("Data=%s\n", job.Data())
        return nil
    }

    w.AddServer("tcp4", "127.0.0.1:4730")
    w.AddFunc("ToUpper", ToUpper, worker.Unlimited)

    if err := w.Ready(); err != nil {
        log.Fatal(err)
        return
    }

    w.Work()
}

console:

2014/10/01 10:17:09 Starting ...
2014/10/01 10:17:12 ToUpper: Data=[hello world]
2014/10/01 10:17:12 EOF
exit status 1
@mikespook
Copy link
Owner

Could you show me the version of gearmand and OS environment and the client code?

@ergoz
Copy link
Author

ergoz commented Oct 8, 2014

Hello.

CentOS 6.5 Final x86_64

Name: libgearman
Arch: x86_64
Version: 1.1.8
Release: 2.el6

Name: gearmand
Arch: x86_64
Version: 1.1.8
Release: 2.el6

No problems with php and python, problems only with this extention :(

@ergoz
Copy link
Author

ergoz commented Nov 5, 2014

Client code included to server code

func ToUpper(job worker.Job) ([]byte, error) {
    log.Printf("ToUpper: Data=[%s]\n", job.Data())
    job.SendData(job.Data())
    job.UpdateStatus(1, 1)
    return nil, nil
}

this function used to process gearman data.

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

No branches or pull requests

2 participants