Introducing Background Jobs for Parse Server

After several weeks in beta, we are happy to announce that background jobs is now generally available on NodeChef for all Parse Server customers. Background jobs has been a heavily requested feature since we started offering hosted Parse Server and MongoDB. The absence of background jobs was holding back many Parse developers from migrating their apps to NodeChef. We are certainly excited about this announcement as we continue to provide Parse customers the best overall experience.

Parse.Cloud.job( 'FeedFetch', function ( request, status ) { status.message( 'I am running in the background!' ); Parse.Cloud.httpRequest({ url: '' }).then(function(httpResponse) { // success console.log(httpResponse.text); status.success('OK'); },function(httpResponse) { // error status.error('ERROR: ' + httpResponse.status); console.error('ERROR: ' + httpResponse.status); }); }); /** Define your jobs in the jobs.js file. The jobs.js file can reference other modules in the current project and any npm module **/

Note that status.success( ) or status.error( ) must be called in your code for the background process to exit. Not calling this will result in a process leak which will eventually crash the app container. Once status.success( ) or status.error( ) is called, the background process running the job will exit immediately. You can explicitly kill long running jobs from the dashboard.

To configure background jobs on NodeChef:

  • Create a file with name jobs.js. This file should be put in the cloud code folder and should follow all the rules of cloud code on the Parse Server.
  • Deploy your cloud code as is using deploy –ccode. The Parse Server will detect the jobs.js file and load the code.
  • Once you have deployed your code, head to the NodeChef dashboard → Task Manager → App Actions → Background jobs to schedule your jobs. There are many options available to customize the frequency of your jobs, including the start time. You can also view the status of any currently running jobs or previous jobs that have been completed.
Schedule Parse Server Background Jobs - NodeChef

For more information about background jobs, check out the Parse Server Guide.