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

🚀 Feature: Allow to capture shutdown event to make db integrations possible #5688

Open
2 tasks done
nev-21 opened this issue Jun 12, 2023 · 2 comments
Open
2 tasks done
Assignees
Labels
product / functions Fixes and upgrades for the Appwrite Functions.

Comments

@nev-21
Copy link

nev-21 commented Jun 12, 2023

🔖 Feature description

I'm connecting to an external database using a dunction, just to make an integration (not to bypass appwrite).

When the container (that is executing a function) is turned off, allow to capture the graceful shutdown, maybe via SIGTERM, to execute an async method that will destroy the db connections. I tried with process.on('SIGTERM', async () => .....) but it doesn't work.

🎤 Pitch

There are many use cases that needs integrations (sometimes a direct connection to an external db is better to make an api) but It is necessary to close the connections when the container turns off (to avoid db connection leaks).

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@byawitz
Copy link
Member

byawitz commented Jun 12, 2023

Maybe, adding a shutdown function to the primary function.
For example for the JS starter version.

const sdk = require('node-appwrite');

module.exports = async function(req, res) {
  const client = new sdk.Client();

  /* rest of starter code */

  res.json({
    areDevelopersAwesome: true
  });
};

module.exports.shutdown = async function(req, res) {
  const client = new sdk.Client();

  /* 
   * Run any shutdown logic code.
   * 
   * This function will execute only when the container is about
   * to get destroyed.
   */
  
};

@nev-21
Copy link
Author

nev-21 commented Jul 5, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product / functions Fixes and upgrades for the Appwrite Functions.
Projects
None yet
Development

No branches or pull requests

3 participants