All Products
Search
Document Center

Function Compute:How to prevent zombie processes in custom runtimes?

Last Updated:Jan 10, 2025

Possible causes

Zombie processes may be generated due to code errors.

Solutions

If you select Web Function and configure Startup Command when you create a function, the process whose process ID (PID) is 1 in the system is the startup command. Therefore, you need to configure a startup command that has the ability to recycle zombie processes.

  • You can use Bash scripts to start programs. Bash processes have the abilities to recycle zombie processes. For example, you can configure Startup Command as /code/start.sh. The following code snippet shows the content of start.sh.

    #!  /bin/bash
    python /code/app.py 
  • If you use Serverless Devs or call an API operation, you can name the startup script as bootstrap and leave Startup Command unspecified. In a function that does not have Startup Command configured, Function Compute attempts to start the function by using the /code/bootstrap script.