metacall / faas

Reimplementation of MetaCall FaaS platform written in TypeScript.
https://dashboard.metacall.io
Apache License 2.0
13 stars 20 forks source link

Readiness does not wait for scripts to be loaded #50

Closed viferga closed 1 month ago

viferga commented 1 month ago

Examining the code of autoDeploy I realized that it is very similar to deploy. We should unify them whenever possible.

Another thing we also can do is add a promise for when the script has been loaded, I am not sure if we should wait in the deploy, or return 200 and then detect when it has been loaded in another way.

And for the autoDeploy, we should wait until the whole list has been loaded.

Another thing that I also thought about is to get the signal when it segfaults or the process exits. We can do this by:

process.on('exit', (code, signal) => {
  // Only on linux..: exit(139): It indicates Segmentation Fault which means that the program was trying to access a memory location not allocated to it. 
  if (code == 139) {
    reject()
  }
});

The readiness endpoint should return 200 only when autoDeploy has loaded everything. And respect to the deploy, we should have an intermediate state until it has been deployed. And resolve the deployment in the table once the OK from the process has arrived.

viferga commented 1 month ago

Solved: https://github.com/metacall/faas/commit/75413990e1bf97db786c5b87b67c3993ffe5d0e1