From 018fb25abb302e76ef838a11d7ea1c6b017997d9 Mon Sep 17 00:00:00 2001 From: Bastien DUMONT <bdumont@grandlyon.com> Date: Fri, 16 Jun 2023 14:00:53 +0000 Subject: [PATCH] Update running services locally --- docs/ecolyo/technical/services/index.md | 94 +++++++++++++------------ 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/docs/ecolyo/technical/services/index.md b/docs/ecolyo/technical/services/index.md index 364c685..3ec602a 100644 --- a/docs/ecolyo/technical/services/index.md +++ b/docs/ecolyo/technical/services/index.md @@ -1,46 +1,48 @@ -# Description - -In order to build an automated task within our cozy-stack, we can create *services* which are javascript files called from a trigger job. - -For instance on Ecolyo, to schedule a mail that alert the user that a new **monthly report** is available in the application, we add a trigger that is launched every month with a *cron* attribute. On that trigger we link a .js script then we instantiate this script with cozy-client. - -## Configuration - -### Manifest - -The service should be described in the manifest.webapp file. it should defined the type, the file and the trigger. See more information in the official doc of Cozy [here](https://docs.cozy.io/en/howTos/dev/services/) - -Here is an example of service declaration in the ecolyo manifest: - - - -File location is determined after the build, see [here](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/tree/build/services/monthlyReport). - -!!! note "Cron" - See the cron definition at [cozy-stack](https://docs.cozy.io/en/cozy-stack/jobs/#cron-syntax). - -## Ecolyo services - -Service code are located under `src\targets\services`. - -## Run services - -### On alpha - -To run services on alpha, a script `get_instance_triggers.sh` allows you to get triggers associated with services. You can find the corresponding service by looking at the trigger frequency and comparing it with our [manifest.webapp](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/blob/dev/manifest.webapp#L171). - -Then you need to run the script `launch_instance_trigger.sh`. - -### Locally - -To run services on a local dev environment, you need to run a build first. - -Then you need to run : - -```sh -yarn run cozy-konnector-dev -m manifest.webapp <service.js> -# example -yarn run cozy-konnector-dev -m manifest.webapp ./build/services/enedisHalfHourMonthlyAnalysis/ecolyo.js -``` - -More details on the [cozy docs / Services / Execution](https://docs.cozy.io/en/howTos/dev/services/#execution). +# Description + +In order to build an automated task within our cozy-stack, we can create *services* which are javascript files called from a trigger job. + +For instance on Ecolyo, to schedule a mail that alert the user that a new **monthly report** is available in the application, we add a trigger that is launched every month with a *cron* attribute. On that trigger we link a .js script then we instantiate this script with cozy-client. + +## Configuration + +### Manifest + +The service should be described in the manifest.webapp file. it should defined the type, the file and the trigger. See more information in the official doc of Cozy [here](https://docs.cozy.io/en/howTos/dev/services/) + +Here is an example of service declaration in the ecolyo manifest: + + + +File location is determined after the build, see [here](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/tree/build/services/monthlyReport). + +!!! note "Cron" + See the cron definition at [cozy-stack](https://docs.cozy.io/en/cozy-stack/jobs/#cron-syntax). + +## Ecolyo services + +Service code are located under `src\targets\services`. + +## Run services + +### On alpha + +To run services on alpha, a script `get_instance_triggers.sh` allows you to get triggers associated with services. You can find the corresponding service by looking at the trigger frequency and comparing it with our [manifest.webapp](https://forge.grandlyon.com/web-et-numerique/factory/llle_project/ecolyo/-/blob/dev/manifest.webapp#L171). + +Then you need to run the script `launch_instance_trigger.sh`. + +### Locally + +To run services on a local dev environment, you need to run a build first. + +Then you need to run : + +```sh +yarn run cozy-konnector-dev -m manifest.webapp <service.js> +# example +yarn run cozy-konnector-dev -m manifest.webapp ./build/services/enedisHalfHourMonthlyAnalysis/ecolyo.js +``` + +_Don't forget to delete `token.json`_ + +More details on the [cozy docs / Services / Execution](https://docs.cozy.io/en/howTos/dev/services/#execution). -- GitLab