Vjardel
Vjardel

Reputation: 1075

Parse.com to Heroku: use background job with heroku and scheduler

I would like to use the first function sayHello in my jobs.js in parse-server-example.

In my jobs.js I have this:

var Parse = require('parse/node');
Parse.initialize('xx', 'xx','xx');
Parse.serverURL = 'xx';
Parse.Cloud.useMasterKey();

function sayHello() {
console.log('Hello');
}

I tried to run it with this terminal line command:

heroku run sayHello -a myAppName

returns:

Running sayHello on myAppName... up, run.6148
bash: sayHello: command not found

Upvotes: 1

Views: 376

Answers (1)

Ben Devore
Ben Devore

Reputation: 56

You should put the job you want to run in its own file (without a .js extension) outside of a function.

    var Parse = require('parse/node');
    Parse.initialize('xx', 'xx','xx');
    Parse.serverURL = 'xx';
    console.log('Hello');

You can then run the following from the command line.

    heroku run node nameOfFile --app yourAppName

Upvotes: 4

Related Questions