culebrón
culebrón

Reputation: 36513

Meteor job-collection not running remote jobs

With vsivsi:job-collection, I've set up jobs like in the example, but the difference is my jobs are processed on the server. And I can't see what's missing compared to the example app, which processes jobs on the client.

lib/db.coffee

@ParsingJobs = JobCollection('parsing', {
    workTimeout: 10000
    transform: (d) ->
        try
            res = new Job(ParsingJobs, d)
        catch e
            res = d
        return res
})

if Meteor.isServer
    Meteor.startup(->
        ParsingJobs.allow({
            admin: (user_id, method, params) ->
                # commented temporarily Roles.userIsInRole(Meteor.user(), ['admin'])
                true
        })

        ParsingJobs.startJobServer()

server.coffee

que = ParsingJobs.processJobs('parsing', {workTimeout: 10000}, (job, cb) ->
    # do some processing
    job.done('success')
    cb()

ParsingJobs.find({type: 'parsing', status: 'ready'}).observe
    added: ->
        que.trigger()

On the client I can just run a shell command:

x = ParsingJobs.find().fetch()[0]
x.rerun()

Result:

job_class.js:16 Uncaught Error: Job remote method call error, no valid invocation method found.

What am I doing wrong?

Upvotes: 0

Views: 140

Answers (1)

maxko87
maxko87

Reputation: 2940

Change this line:

que = ParsingJobs.processJobs('parsing', {workTimeout: 10000}, (job, cb) ->

to this:

que = Job.processJobs('parsing', {workTimeout: 10000}, (job, cb) ->

Upvotes: 1

Related Questions