How To Run Habitual Jobs the usage of Velo through Wix

(*11*)

(*7*)

@veloVelo through Wix

Velo is a full-stack construction platform that empowers you to unexpectedly construct, organize and deploy skilled internet apps.

The Task Scheduler means that you can agenda code to run at specified durations. You agenda code to run through developing a role.

Each and every task defines what code to run and when to run it. The code your task runs can also be any backend serve as. You’ll agenda that code to run on an hourly, day-to-day, weekly, or per 30 days foundation.

As an example, you may create jobs that:

  • Import knowledge from an exterior supply as soon as an afternoon.
  • Delete assortment knowledge this is now not related as soon as per week.
  • Ship a standing report back to related events as soon as a month.  

Configuring Jobs

You configure what jobs to run and when to run them within the jobs.config report discovered for your website’s Velo Sidebar, within the Code Information, Backend phase.

To create a jobs.config report:

  1. Hover over the Code Information, Backend phase within the Velo Sidebar.
  2. Click on the upload icon.
  3. Choose Task Scheduler

The jobs.config report comprises a JSON object which defines the scheduled jobs. The item is composed of the houses indexed beneath.

Observe: You will have to submit your website to save lots of adjustments for your jobs configuration.

jobs (Array)

The roles object comprises one top-level key named “jobs”. The important thing maps to an array of items, every of which represents a scheduled task. Each and every scheduled task object comprises the “functionLocation”, “functionName”, “description” and “executionConfig” houses which might be detailed beneath.

Observe: You’ll configure as much as 20 jobs. The primary 2 choices beneath are for 1 task handiest. The third possibility describes what a jobs report looks as if with a couple of jobs.

Possibility 1 – The use of a CRON expression

{ "jobs": [ { "functionLocation": "/module/filename.js(w)", "functionName": "funcName", "description": "describe your job", "executionConfig": { "cronExpression": "0 8 * * *" } } ]
}

Possibility 2 – Environment the time, day of week, and day of month

Necessary: Each strains 9 and 10 supply non-compulsory period controls in your task. If you do not want that point of keep watch over you’ll delete both or each out of your code. In case you delete line 10 you’ll want to additionally delete the comma on the finish of line 9.

(*18*)

{ "jobs": (*3*)
}

jobs.config with greater than 1 task

Observe: The next is an instance of what the roles.config report looks as if with greater than 1 task (3, on this case), the usage of a CRON expression. It’s supposed to show the construction of the array of items with greater than one object. As famous above, you’ll agenda as much as 20 jobs, and to try this you can upload extra items following the trend described right here. Observe that there’s a comma between every object (strains 10 and 18) however that the general object does now not have a comma afterwards (line 26).

{ "jobs": (*2*)
}

functionLocation (String)

The site of the report of the backend serve as that comprises the serve as you wish to have to run on the scheduled time. The serve as can also be any serve as in any backend .js or .jsw report. The serve as location is a relative trail throughout the Backend folder.

As an example, if you wish to run the deleteExpired() serve as as proven beneath:

(*5*)

Set the “

functionLocation

” worth to “

/utils/dbUtils.js

“.

functionName (String)

Identify of the serve as you wish to have to run on the scheduled time.

Necessary: You’ll want to export the serve as that you wish to have the task scheduler to name.

As an example, if you wish to run the deleteExpired() serve as as proven beneath:

(*6*)

Set the “

functionName

” worth to “

deleteExpired

“.

description (String) – non-compulsory

An outline of the task.

executionConfig (Object)

An object containing details about when the task must run. You’ll outline when the task runs the usage of a cron expression or through specifying a time of day and optionally an afternoon of the week or date within the month.

Necessary:

  • Jobs occuring greater than as soon as an afternoon will have to be outlined the usage of a cron expression.
  • If each specs exist for a unmarried task, handiest the cron expression will likely be used.

Cron Expression

When the usage of a (*10*)cron expression to specify when a role runs, the “

executionConfig

” object comprises a unmarried assets, named “

cronExpression

“, whose worth is a legitimate cron expression.

cronExpression (String)

A legitimate (*10*)cron expression. As an example, to run a role on a daily basis at 8:00 within the morning, use:

"cronExpression": "0 8 * * *"

Necessary: When the usage of a cron expression, you’ll agenda your task to run at durations as brief as one hour aside, however now not shorter. In case you outline your task to run extra steadily, the task will likely be neglected.

Time, Day, and Date

Jobs outlined the usage of the “

time

“, “

dayOfWeek

“, and “

dateInMonth

” houses can run on a day-to-day, weekly, or per 30 days foundation. In all circumstances the usage of this feature, the “

executionConfig

” object will have to comprise a “

time

” assets which defines the time of day the task will run.

  • For day-to-day jobs, the “
    executionConfig

    ” object handiest comprises the “

    time

    ” assets.

  • For weekly jobs, the “
    executionConfig

    ” object comprises the “

    time

    ” assets and a “

    dayOfWeek

    ” assets that defines on what day of the week the task runs.

  • For per 30 days jobs, the “
    executionConfig

    ” object comprises the “

    time

    ” assets and a “

    dateInMonth

    ” assets that defines on what day of the month the task runs.

time (String)

The time of day the task runs. The time is specified as (*9*)UTC time in 

HH:MM

structure.

Observe: The task will run inside of 5 mins after the required time.

dayOfWeek (String) – non-compulsory

For weekly jobs, upload the 

dayOfWeek

 assets to the 

executionConfig

object. The 

dayOfWeek

 assets defines what day of the week the task runs on.

For day-to-day or per 30 days jobs, disregard the 

dayOfWeek

 assets.

The price of the dayOfWeek assets is one of: “

Sunday

“, “

Monday

“, “

Tuesday

“, “

Wednesday

“, “

Thursday

“, “

Friday

“, or “

Saturday

“.

dateInMonth (Quantity) – non-compulsory

For per 30 days jobs, upload the 

dateInMonth

 assets to the

executionConfig

object. The 

dateInMonth

 assets defines what day of the month the task runs on.

For day-to-day or weekly jobs, disregard the dayOfWeek assets.

The price of the 

dateInMonth

 assets is a bunch between 

1

 and 

31

.

In the past printed at (*8*)https://give a boost to.wix.com/en/article/velo-scheduling-recurring-jobs

(*7*)

(*14*)

Comparable Tales

Tags

Sign up for Hacker Midday (*20*)

Create your loose account to liberate your customized studying enjoy.