All Products
Search
Document Center

Serverless App Engine:Configure startup commands

Last Updated:Mar 10, 2025

If you deploy an application by using an image or a code package in the Serverless App Engine (SAE) console, SAE starts containers by using the preset startup parameters of the container image or code package. If you want to configure custom settings, such as NGINX settings, before a container startup, or if you do not want to use the preset startup parameters, you can configure a startup command for your application in SAE to overwrite the preset parameter settings in an image file.

Background

Before you create an image, the startup settings of containers are specified by the ENTRYPOINT or CMD command in the Dockerfile. When containers are started, the commands in the Dockerfile are preferentially run.

In this example, the following command is preset in the Dockerfile. When containers are started, the command is first run.

FROM ubuntu
ENTRYPOINT [nginx, '-g', 'daemon off;']                

Usage notes

You can configure a startup command when you create an application, when you modify a running application or when you deploy an application:

Create an application

  1. Log on to the SAE console. In the left-side navigation pane, choose Applications > Applications. Select a region in the top navigation bar and a namespace from the Application List drop-down list, and click Create Application.

  2. Configure the required parameters on the Basic Information page, and click Next: Advanced Settings.

Modify a running application

Warning

After you redeploy an application, the application is restarted. To prevent unpredictable errors such as business interruptions, we recommend that you deploy applications during off-peak hours.

  1. Log on to the SAE console. In the left-side navigation pane, choose Applications > Applications. Select a region in the top navigation bar and a namespace from the Application List drop-down list, and click the name of the target application.

  2. On the Basic Information page that appears, click Deploy Application.

Modify a stopped application

  1. Log on to the SAE console. In the left-side navigation pane, choose Applications > Applications. Select a region in the top navigation bar and a namespace from the Application List drop-down list, and click the name of the target application.

  2. On the Basic Information page that appears, click Modify Application Configurations.

Configure startup commands for applications

Applications deployed by using images

In this example, startup commands are configured for a Java application.

In the Startup Command section, select a startup method and configure startup command for the container.

  • >_ /bin/sh

    sh -c 'while true; do echo hello; sleep 10;done'
  • >_ /bin/bash

    bash -c 'while true; do echo hello; sleep 10;done'

sBXB3VO8G5

Applications deployed by using JAR packages

To start or run a Java application, you must configure a startup command and parameters, such as the Java virtual machine (JVM) and garbage collection (GC) parameters.

SAE automatically compiles the JAR package that you uploaded into an image, uploads the image to the image repository, and then runs the application as containers. During the compilation, SAE uses the built-in startup command and parameters, and specifies the storage path of the JAR package. You can log on to the SAE console to modify the default startup command and command parameters.

Important

If the startup command is invalid, the application fails to be created. If you are not familiar with the ENTRYPOINT and CMD command in the Dockerfile, we recommend that you do not configure a custom startup command and parameters or modify the default startup command and parameters.

In the Startup Command Settings section, configure the parameters. The following figure shows the configurations of a sample startup command.

dQolzyE4Iu

Parameter

Description

Default Startup Command

The default startup command that is provided by SAE.

Options Settings

The JVM parameters. For more information, see, see JVM options, Tuning Java Virtual Machines, and JVM Tuning: How to Prepare Your Environment for Performance Tuning.

If you want to use the remote debugging feature of the application, configure the following command according to the JDK version.

  • JDK 11 and JDK 17

    -agentlib:jdwp=transport=dt_socket,address=*:9000,server=y,suspend=n
  • Other JDK versions

    -agentlib:jdwp=transport=dt_socket,address=9000,server=y,suspend=n

Where:

  • transport: the data transmission method for remote debugging.

  • address: the IP address of the client from which the O&M engineer performs remote debugging. Use the port that you specified when you enabled remote debugging. For more information, see Perform remote debugging.

Important

The startup command that is used when you deploy an application by using a WAR package is different from the startup command that is used when you deploy an application by using a JAR package. We recommend that you do not use the same startup command when you deploy applications by using different methods. You can use the preceding remote debugging command to debug an application regardless of whether you use a WAR package or a JAR package to deploy the application.

args Settings

The redirection parameter for standard output (stdout) and standard errors (stderr). Example: 1>>/tmp/std.log>&1.

Applications deployed by using WAR packages

In the Startup Command Settings section, configure the parameters. The following figure shows the configurations of a sample startup command:

nGwm0XDLnO

Parameter

Description

Default Startup Command

The default startup command that is provided by SAE.

options Settings

The JVM parameters. For more information, see JVM options, Tuning Java Virtual Machines, and JVM Tuning: How to Prepare Your Environment for Performance Tuning.

If you want to use the remote debugging feature of the application, configure the following command according to the JDK versions.

  • JDK 11 and JDK 17

    -agentlib:jdwp=transport=dt_socket,address=*:9000,server=y,suspend=n
  • Other JDK versions

    -agentlib:jdwp=transport=dt_socket,address=9000,server=y,suspend=n

Where:

  • transport: the data transmission method for remote debugging.

  • address: the IP address of the client from which the O&M engineer performs remote debugging. Use the port that you specified when you configure remote debugging. For more information about remote debugging feature, see Perform remote debugging.

Important

The startup command that is used when you deploy an application by using a WAR package is different from the startup command that is used when you deploy an application by using a JAR package. We recommend that you do not use the same startup command when you deploy applications by using different methods. You can use the preceding remote debugging command to debug an application regardless of whether you use a WAR package or a JAR package to deploy the application.

Applications deployed by using ZIP packages

In the Startup Command section, select a startup method and configure the startup command for the container.

  • >_ /bin/sh

    sh -c 'gunicorn -w 3 -b 0.0.0.0:8080 app.hello:app'
  • >_ /bin/bash

    bash -c 'gunicorn -w 3 -b 0.0.0.0:8080 app.hello:app'

FWP1NqMoGb