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

Cloud Jobs Guidance #153

Closed
anthonysg opened this issue Feb 1, 2016 · 32 comments · Fixed by #7561 · 4 remaining pull requests
Closed

Cloud Jobs Guidance #153

anthonysg opened this issue Feb 1, 2016 · 32 comments · Fixed by #7561 · 4 remaining pull requests
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version

Comments

@anthonysg
Copy link

Hello, from what I understand, cloud jobs are not working in parse-server. It states the following in the migration docs:

Jobs

There is no Job functionality in Parse Server. If you have scheduled jobs, port them over to a self-hosted solution using a wide variety of open source job queue projects. A popular one is kue. Alternatively, if your jobs are simple, you could use a cron job.

I am wondering if a tutorial could be made showing how to modify already-made cloud jobs to run using kue. Either that or it would be really nice if somebody could implement this functionality.

@gfosco
Copy link
Contributor

gfosco commented Feb 1, 2016

I agree a guide would be handy. We've been leaning towards telling developers to build node scripts for this and trigger them with a cron scheduler... but yeah, an example would be great.

@gfosco gfosco changed the title Cloud Jobs Functionality Cloud Jobs Guidance Feb 1, 2016
@grassland-curing-cfa
Copy link

My Cloud code (main.js) contains a Job function:
Parse.Cloud.job("jobRequestForValidation", function(request, status) {
... ...});

This caused failure of deployment of my app on Heroku.

So I had to remove the Job from the main.js so that deployment was successful.

@gfosco
Copy link
Contributor

gfosco commented Feb 26, 2016

Going to close this for lack of activity. Guidance for cloud jobs will likely vary based on the deployment platform of choice (i.e. the Scheduler addon for heroku, or some cron script for a VPS).

@AmbroiseCollon
Copy link

Hi, I'm setting up a tutorial on Kue + Heroku. In order to finish it, I need help on this issue #1078. Thanks and I hope you'll like it ^^!

@mdtempalert
Copy link

I use the following for simple jobs:

if (!Parse.Cloud.job) {
    Parse.Cloud.job = function(name, func) { 
        app.get("/jobs/" + name, func);
    };
} 

Where app is my express instance in the same scope. This function exposes jobs as GET endpoints from my server. For instance, a job called MyJob could be run by hitting /jobs/MyJob.

@rendragon83
Copy link

Does anyone know if there are any news on any tutorials for this. I keep hitting rode blocks trying to set this up.

@gateway
Copy link

gateway commented Oct 12, 2016

I have to kick this as well, I have seen some info on jobs but no wiki or docs on the best way or best practices for this..

@flovilmart
Copy link
Contributor

Parse.Cloud.Job is exposed.

Every job will be exposed through: /jobs/:jobName and protected by the masterKey access.

Job status is recorded in the _JobStatus whenever the jobs starts, ends, error etc... as the old jobs would do.

Jobs are not scheduled, you should handle scheduling calling the job HTTP endpoint yourself (with the masterKey).

You should be able to run the jobs from the parse-dashboard to test your endpoints and see the status of your jobs.

@gateway
Copy link

gateway commented Oct 12, 2016

@flovilmart thanks for your reply, is their some sort of priority we can define for jobs and whats the expected time out that a job might see. I can early have another server do the scheduling via cron and using CURL to run the job. How would be pull _JobStatus back to see the progress, completion etc?

@flovilmart
Copy link
Contributor

There is no priority as there is no schedule, the Job is just the same thing a a cloud function, the only difference is that it's status can be updated for success, error and messages.

You can read the job status in the dashboard or make a query on it "_JobStatus".

@noder199
Copy link

noder199 commented Oct 13, 2016

Jobs are not scheduled, you should handle scheduling calling the job HTTP endpoint yourself (with the masterKey).

So how should we do this if we want the job(s) to be scheduled? (Open to anyone's answer) I am using google app engine, and I understand there is some sort of scheduler but it is not cron-based. Would that work?

@flovilmart
Copy link
Contributor

You can use app engine cron.yaml To schedule the calls to the jobs end points.

@gateway
Copy link

gateway commented Oct 20, 2016

I should of asked, but do jobs time out after x minutes?

@afgarcia86
Copy link

This was pretty difficult for me to figure out so I am just going to post a full url example here in hopes it saves someone else time.

Basically I used Postman to Post to a url like http://localhost:1337/parse/jobs/:jobName while having the following headers set. X-Parse-Application-Id and X-Parse-Master-Key.

@flovilmart
Copy link
Contributor

@gateway they don't
@afgarcia86 that is how to run them, use the same method in a scheduler if you need to.

@chadpav
Copy link

chadpav commented Jan 26, 2017

FYI, I've successfully used a web cron service as an external scheduler so that I didn't have to maintain an additional bit of infrastructure.

https://www.setcronjob.com

P.S. - I have no affiliation w/ this service. It's just the one I happened to use and it worked for me.

@devKC
Copy link

devKC commented Mar 12, 2017

@flovilmart - for AWS worker tier, cron.yaml is to be formatted as:

version: 1
cron:

  • name: "backup-job"
    url: "/backup"
    schedule: "0 */12 * * *"

Where would I include the parse app id and masterkey? Would it look like below?

url: "/backup"
headers: {
X-Parse-Application-Id: appId
X-Parse-Master-Key: masterKey
}
schedule: "0 */12 * * *"

Any guidance would be greatly appreciated!

@flovilmart
Copy link
Contributor

On Google cloud, I'm using something similar with app engine CRON. I have deployed a very simple JavaScript web app that listen on /job/:jobName and forwards the HTTP call to parse server. This way, I use app engine cron for scheduling as I can't pass the headers either.

You should probably look for something similar on AWS.

@devKC
Copy link

devKC commented Mar 16, 2017

@flovilmart - just checking, when you are forwarding the HTTP call to parse server, are you passing along the app_id/master_key values in headers by using something like headers option for require('request')? If so, how secure is it to send the request with keys in the headers? I would assume I wouldn't hardcode the key values in the headers options but use env var, but since the values are being sent in the post request I was wondering if it is recommended to protect the values, i.e. encryption, etc.

@flovilmart
Copy link
Contributor

I make HTTPS requests from the 'worker' so yes I pass my masterKey in the header.

@acinader
Copy link
Contributor

acinader commented Mar 16, 2017

@devKC AWS worker tier? huh? you got a link to what you are talking about? What I've been doing for scheduled jobs is to set an event in AWS Cloud Watch which invokes a lambda that then sends the request. Its problematic in a few ways: 1. its way too complicated, every time i have to touch it, i need to re-wrap my head around it. 2. it doesn't guarantee that the event will only fire once, so I have to code around that, so if there is some AWS worker tier thing...I need to read up on it....

@AmbroiseCollon
Copy link

I finally went on using agenda which is based on MongoDB and therefore plays nicely with ParseServer. After trying Kue, node package crontab, standard cron, agenda ended up being the best option for me.

@danielchangsoojones
Copy link

danielchangsoojones commented Jun 28, 2017

If anyone is using Parse Server and Heroku, I just used Heroku Scheduler to schedule jobs. It bypasses the need to create a Cloud Job. It's very quick and easy. Here's a tutorial.

@flovilmart
Copy link
Contributor

We implemented a job runner, https://github.com/ampme/Parse-server-job-runner , it just needs to run periodically and will work with the jobSchedule objects (re-introduced in 2.5.0 and next dashboard release)

@aliasad106
Copy link

@flovilmart How will it be possible to use it with Cron ?

@flovilmart
Copy link
Contributor

You should ask on the parse-server-job-runner repository

@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0-alpha.2

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Oct 27, 2021
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0-beta.1

@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 4.10.5

@parseplatformorg parseplatformorg added the state:released-4.x.x Released as LTS version label Feb 12, 2022
@parse-github-assistant
Copy link

The label state:released-4.x.x cannot be used here.

@parse-github-assistant parse-github-assistant bot removed the state:released-4.x.x Released as LTS version label Feb 12, 2022
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment