Is there a way to debug scheduled jobs in Corvid?
I have created a jobs.config according to the guidelines. I have tested the function I am calling and it works as expected when run manually. However, I cannot seem to get the function to run based on the schedule.
Things I have tried:
1. I have the "Site Monitoring" open over periods of time when the jobs should run. No logs for scheduled events.
2. I have created a new collection called "Scheduled Jobs" which I write to at the beginning and the end of the scheduled job function I call. No updates to this table when called via schedule, but works when called manually.
Questions that may help me debug further:
1. What permission level is a scheduled job given? (Although I do have all collection writes as "SuppressAuth", but the module itself is restricted to "Admin")
2. Does jobs.config allow comments or do I need to delete all of those (i.e., is this pure json)? Sample file had some comments throughout and no errors in the wix editor with comments.
Are there any other ways to see errors from the scheduled jobs in order to help me isolate the problem?
Example entry in my jobs.config file:
// -- 9 AM -- { "functionLocation": "updateRegistrations.updateLaRegistrations", "description": "9am Get latest registrations", "executionConfig": { "time": "13:00" // mandatory, “hh:mm” format } },
Still no luck here. New things I've tried.
- Remove all comments
- Ensure I have fewer than 20 jobs
- Make jsw file open to everyone instead of restricted to admin
- Move code to .js file instead of .jsw
- Move .js file into folder like described in docs and use /folderName/filename.functionname
- Make sure I'm waiting 5 minutes before checking as described in docs
@Yisrael (Wix) @stcroppe @Aleksander Denga
Been having the exact same issue for the past two weeks. No responses yet.
I'm by no means an expert here, but I think part your problem is the comma. I've been fighting with my schedule for the last couple of days and just figured it out. I had forgotten/didn't notice to remove a comma that was there in the template provided since I was only running 1 job. The other problem is that I think your "function location": should be "/updateRegistrations.updateLaRegistrations",
Incase it helps, another issue that I had was calculating UTC properly. At first I thought UTC and GMT were interchangeable, however GMT does shift an hour for daylight savings whereas UTC never changes.
Thanks for the possible hints. I have run it through a json validator to check for any extra commas and such. That is coming out clean. I've also tried a lot of variations of the path with no luck either. `./updateRegistrations.updateLaRegistrations`, `/updateRegistrations.updateRegistrations`, moving it into a folder like the doc such as `/utils/updateRegistrations.updateRegistrations`.
Watch the Wix youtube video if still struggling.
https://www.youtube.com/watch?v=l9r2SIvKnBM
Thanks for the link. I scanned through the video quick and it seems to be out of date relative to the docs. For example, in the video, it says you should use a jsw module; however, in the latest version of the docs it says you must use .js files. https://support.wix.com/en/article/corvid-scheduling-recurring-jobs
I have tried both jsw and js files along with some of the other setup here.
Is the doc more up to date than the video or is the video the correct source of truth?
@Nick V
Yes that is the question, I would go with the video as that is from August this year.
https://www.wix.com/corvid/forum/corvid-tips-and-updates/video-how-to-execute-timed-tasks-with-the-job-scheduler
Although you would hope that the tutorial page and the video would both be the correct versions to use and they would both relate to each other.
Hopefully somebody from Wix comes back and says that the video for it is still relevant and can be used that way as well as in the actual tutorial for it.
@Lior Wiseman @Yisrael (Wix)
Especially as the tutorial states that you have to use js backend files and that you can only do up to the max 20 jobs, whereas the video says that you can use jsw backend files too.
The location of the backend function that will run at the scheduled time. The function can be any function in any backend .js file.
Note:
You can configure up to 20 jobs.
.jsw and .js should be both supported as well as Admin permissions for the database
Here is a copy of mine, which works. You could try using this and modifying it for yours. I have found that if I put a remark (// or /* */) anywhere after the first "{" then it doesn't work.
Thanks for the help everyone! I finally got one to run. I deleted all of the jobs except for one and took everything I learned from your comments and from the docs and applied it.
It looks like there is some validation happening that we aren't told about. If any of the jobs are invalid, none of them run. At least based on the evidence I have gathered so far. I was trying to be efficient and run a different type every 15 minutes and I think that's what bit me.
I definitely recommend adding code to write to a separate table at the start and end of the job so that you can easily see if a job ran or not.
I have put back some additional jobs and will see if those run tomorrow.
Can you post your final jobs.config? I still haven't had success with it.
Also, instead of writing to two separate tables, you can debug your backend code very easily using the live events monitoring in your dashboard. https://support.wix.com/en/article/corvid-viewing-live-site-events
That live-site-events has been really helpful. Writing to the table was a useful strategy for scheduled events in particular because I could check back later to see if they ran rather than constantly having that live events tab open. I also didn't have the resources to purchase/setup external logging so I could search back or search later. It's nice to see exactly when the scheduled job ran and have it permanently logged.
I've scrubbed this a bit but here is what eventually worked for me.
{
"jobs": [
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "915a Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "13:15"
}
},
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "1015a Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "14:15"
}
},
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "1115a Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "15:15"
}
},
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "1215p Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "16:15"
}
},
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "115p Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "17:15"
}
},
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "215p Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "18:15"
}
},
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "315p Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "19:15"
}
},
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "415p Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "20:15"
}
},
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "515p Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "21:15"
}
},
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "615p Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "22:15"
}
},
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "645p Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "22:45"
}
},
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "715p Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "23:15"
}
},
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "745p Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "23:45"
}
},
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "815p Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "01:15"
}
},
{
"functionLocation": "/updateRegistrationsJs.updateRegistrations",
"description": "915p Get latest registrations from ExternalSystem",
"executionConfig": {
"time": "02:15"
}
}
]
}
Copying the list of tips I developed after going through this out here so it isn't buried in the thread.
https://www.wix.com/corvid/forum/main/comment/5d94d96194a5d5007fcbdc95
Note from @Lior Wiseman
- js and jsw should be supported
- scheduled jobs do run as admin and so specifying admin permissions should be supported
https://www.wix.com/corvid/forum/main/comment/5d950d617c02dc0017534e16