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 information
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 or when you deploy an application.
When you create an application, you can configure a startup command in the Deployment Configurations step of the Create Application page.
When you deploy an application, perform the following operations based on the number of instances in the application:
If the number of instances is greater than or equal to 1, click Deploy Application on the Basic Information page of the application. On the Deploy Application page, configure the parameters based on your business requirements.
If the number of instances is 0, click Modify Application Configurations on the Basic Information page of the application. On the Modify Application Configurations page, configure the parameters based on your business requirements.
NoteAfter the configurations of an application are modified, the configurations take effect the next time the number of instances in the application exceeds 0.
The steps to configure a startup command are similar regardless of the method that you use to deploy an application and the environment in which you deploy the application. However, the startup command and parameters that you can configure vary. Follow the on-screen instructions to proceed.
Configure a startup command when you deploy an application by using an image
Configure a startup command when you deploy an application by using a JAR package
Configure a startup command when you deploy an application by using a WAR package
Configure a startup command when you deploy an application by using a ZIP package
Configure a startup command when you deploy an application by using an image
In this example, a Java application is created. In the Deployment Configurations step, set the Application Deployment Method parameter to Image. In the Startup Command Settings section, configure the parameters. If you set the Startup Mode parameter to Docker Native, run the command that is shown in the following figure.
In this example, the ENTRYPOINT: [nginx, '-g', 'daemon off;']
command is configured. The following table describe the parameters in the command.
Parameter | Description |
Startup Command | Enter a startup command. Example: |
Startup Parameter | Enter a startup parameter. Example: Click + Add to add a parameter in a new line. Example: |
Configure a startup command when you deploy an application by using a JAR package
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.
If the startup command is invalid, the application fails to be created. If you are not familiar with the ENTRYPOINT or 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 this example, a Java application is created. In the Deployment Configurations step, set the Application Deployment Method parameter to Deployment with JAR Packages. In the Startup Command Settings section, configure the parameters. The following figure shows the configurations of a sample startup command.
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 version:
where:
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: |
options Shortcut Settings | This parameter is available only if you set the Java Environment parameter to Dragonwell.
|
Configure a startup command when you deploy an application by using a WAR package
In this example, a Java application is created. In the Deployment Configurations step, set the Application Deployment Method parameter to Deployment with WAR Packages. In the Startup Command Settings section, configure the parameters. The following figure shows the configurations of a sample startup command.
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 version:
where:
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. |
options Shortcut Settings | This parameter is available only if you set the Java Environment parameter to Dragonwell.
|
Configure a startup command when you deploy an application by using a ZIP package
In this example, a Python application is created. In the Deployment Configurations step, set the Application Deployment Method parameter to Deployment with ZIP Packages. In the Startup Command Settings section, configure the parameters. If you set the Startup Mode parameter to Shell Script, run the following command:
gunicorn -w 3 -b 0.0.0.0:8080 app.hello:app