Create one-off administration tasks or scripts.
During the deployment process, these tasks can be executed against staged applications. The platform creates a new container for them, where they are performed for a specific period until they are completed, after which the container is deleted.
One-off tasks are modeled in accordance to the following structure:
_schema-version: "3.1" ID: foo version: 3.0.0 modules: - name: foo type: javascript.nodejs parameters: no-route: true no-start: true disk-quota: 2GB tasks: - name: example_task command: npm start memory: 1GB
In the structure above, the parameters stand for the following:
- When the task is triggered, the
npm start
command is executed. - Entering a specific value in the
memory
parameter is optional. A platform-derived default memory size is used for the execution of the task. You can specify a different value if required. - The
no-route
parameter specifies if a route is required. Applications whose only purpose is to perform a task and then be stopped usually do not require a route. The default value isfalse
. - Use the
no-start
parameter if you want only the one-off tasks to be executed, that is, without triggering the start of the application. If you do not define this parameter, tasks are automatically executed after the applications are started.
Тhe values for аpplication memory and task memory do not have a dependency. This is also valid for the allowed disk quota.
For more information about one-off tasks, see MTA Deployment Descriptor Examples.
The following codeblock contains an example for a database migration task:
_schema-version: "3.1" ID: foo version: 3.0.0 modules: - name: foo type: javascript.nodejs parameters: no-route: true no-start: true memory: 1GB disk-quota: 2GB tasks: - name: db_migration command: "bin/rails db:migrate" memory: 256M #This parameter is optional. disk-quota: 128M #This parameter is optional.
Related Information