While most of the time you are probably using the Swisscom Application Cloud to push long running processes (or “apps” as they are commonly called), there is the occasional use case for tasks.
Now tasks in Cloud Foundry are defined as a process that runs only for a finite amount of time, and then stops. A task runs in its own container, inheriting memory and disk limits from its parent app, and should be designed to use minimal resources while executing a “task”. After such a task exits Cloud Foundry will destroy and remove this container again. Tasks can also be checked for their current state and for a success or failure message after they finished.
Documentation on using tasks in Cloud Foundry can be found here: https://docs.developer.swisscom.com/devguide/using-tasks.html
While tasks are a great tool to run short running processes or batch jobs, triggering them manually can be quite tedious. You might want to run your daily database backup every at two o’clock in the morning perhaps, or processing some data every 15 minutes? With any of these the need for some way of automatic scheduling arises.
On the Swisscom Application Cloud there is the Task-Scheduler service available in the marketplace to help you with all your task-scheduling needs.
It is a distributed, highly-available system running in the backend that accepts scheduling requests coming from Cloud Foundry users, creates and manages jobs and their schedule, and executes these jobs as tasks on Cloud Foundry at the scheduled time and date.
Integration into the marketplace is done via the standardized Open Service Broker API, to make the experience seamless for all users of the Swisscom Application Cloud.
Thanks to this a user can simply create service instances, bind these to his apps and define tasks to be scheduled all through the CF CLI without the need for any additional tools.
To use the Task-Scheduler you must first create a service instance of it.
Check the marketplace and you should see the Task-Scheduler service listed there, then create a new service instance:
Once the service instance has been created you can then bind it to an existing app. During binding you specify via binding parameters the requested schedule, task, and optionally memory/disk limit overwrites. The service can be bound to as many different apps as you wish, the binding only acts as a registration action for the Task-Scheduler service:
After binding a Task-Scheduler instance to your app, the configured task will be executed automatically according to the provided cron schedule. To remove the scheduled task again simply unbind the service from the app.
Running or finished tasks can be checked with the CF CLI:
And that’s all there is to it.. We wish you a happy scheduling! ? ?
Senior Cloud Engineer
Trouve le Job ou l’univers professionnel qui te convient. Où tu veux co-créer et évoluer.
Ce qui nous définit, c’est toi.