serverless-offline-scheduler icon indicating copy to clipboard operation
serverless-offline-scheduler copied to clipboard

Nothing happening

Open Meemaw opened this issue 6 years ago • 5 comments

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)  

Meemaw avatar Aug 04 '19 12:08 Meemaw

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

itskemo avatar Dec 18 '19 08:12 itskemo

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

ajmath avatar Dec 26 '19 20:12 ajmath

Hi Ajmath,

This plugin is working with either of these command:

  • sls offline start
  • sls schedule

But not with this command:

  • sls offline

May I know the reason behind it?

m0hdasif avatar Feb 01 '20 16:02 m0hdasif

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...

ErikAndreas avatar Mar 09 '20 09:03 ErikAndreas

@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.

kaskelotti avatar Jun 10 '20 12:06 kaskelotti