serverless-offline-scheduler
serverless-offline-scheduler copied to clipboard
Nothing happening
I'm trying out this plugin via:
λ → sls schedule
Serverless: scheduler: scheduling schedule-executors/schedule-executors with */1 * * * *
Serverless: schedule-executors
and
λ → serverless offline
... but I'm not seeing anything happening.
Functionn is defined as:
functions:
schedule-executors:
handler: src/functions/scheduleExecutors/index.handler
events:
- schedule:
name: your-scheduled-rate-event-name
description: 'your scheduled rate event description'
rate: rate(1 minute)
Make sure to put the serverless-offline-scheduler ABOVE the serverless-offline in the list of plugins:
// serverless.yml
plugins:
# ... other plugins
- serverless-offline-scheduler # <----- keep it above the serverless-offline
# ... other plugins
- serverless-offline
Something else to keep in mind is that this won't launch the functions immediately. For rate(1 minute) functions, it will happen at the 00 second mark every minute. For example, if you run serverless schedule with your function config at 9:01:01, the function won't actually be executed until 9:02:00. You can use the recently added --runSchedulesOnInit cli arg to have them invoked immediately
Hi Ajmath,
This plugin is working with either of these command:
sls offline startsls schedule
But not with this command:
sls offline
May I know the reason behind it?
I get it to run once on init using sls offline start --stage dev --runSchedulesOnInit but then nothing happens and when I stop (ctrl +c) sls then it shows:
Error: Command failed: C:\Program Files\nodejs\node.exe C:\<redacted>\serverless.js invoke local --function rateTest --data {"account":"<redacted>","region":"serverless-offline","detail":{},"detail-type":"Scheduled Event","source":"aws.events","time":"2020-03-09T08:52:14.196Z","id":"<redacted>","resources":["arn:aws:events:serverless-offline:123456789012:rule/rateTest"],"isOffline":true} --stage dev at checkExecSyncError (child_process.js:611:11) at Object.execFileSync (child_process.js:629:15)
sls schedule seems to work but then other plugins (dynamodb etc) are not started...
@m0hdasif the serverless plugins have some sort of "lifecycle" and you need to trigger it with start command in order to startup properly. The same applies for example to AWS DynamoDB local plugin.
Unfortunately I could not find the docs where this is explained.