Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable scheduled functions #1123

Closed
wasenbr opened this issue Nov 4, 2020 · 3 comments · Fixed by #1185
Closed

Disable scheduled functions #1123

wasenbr opened this issue Nov 4, 2020 · 3 comments · Fixed by #1185

Comments

@wasenbr
Copy link

wasenbr commented Nov 4, 2020

Please, could you create a option to disable the scheduled functions.

It could be a command line option like

--disableScheduledFunctions

It's is importante because I have some funcions that manipulate data and I don't want to run it every momment on dev time.

Today, I have 2 yml files to control it:

  • one with all my function enabled
  • another with all the scheduled funcions disabled

With this new options, this process could my simpler.

@acorbel
Copy link

acorbel commented Nov 10, 2020

We faced the same issue.
As a workaround, we use the IS_OFFLINE env var to interrupt the scheduled functions.

exports.handler = () => {
 if (process.env.IS_OFFLINE) return;
...
}

@ghost
Copy link

ghost commented Jan 19, 2021

In order to avoid modifying function source, I'd also appreciate a way to disable scheduled functions from running for serverless-offline.

@madpilot
Copy link

There is another workaround that doesn't require code

You can toggle the enable param on the event definition using an environment variable.

ie:

events:
  - schedule:
      enabled: ${strToBool(${env:ENABLE_SCHEDULER, "false"})}

That will disable the scheduler unless ENABLE_SCHEDULER is present and set to true. The only caveat is you need to opt in in production...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants