When you deploy an application with a container image or code package in the SAE console, SAE uses preset startup parameters to start the container. If you need to perform special configurations, such as for Nginx, when the container starts, or if you do not want to use the preset startup parameters, you can customize the container's startup command. This lets you apply special configurations or override the image's default startup parameters.
Entry points
The procedure varies based on the scenario.
Create an application
Log on to the SAE console. In the left-side navigation pane, choose Applications > Application List. Select the target region and namespace, and then click Create Application.
On the Basic Information wizard page, configure the required settings and click Next: Advanced Settings.
Modify a running application
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.
Log on to the SAE console. In the left-side navigation pane, choose Applications > Application List. Select the target region and namespace, and then click the name of the target application.
On the Basic Information page of the target application, click Deploy Application.
Modify a stopped application
Log on to the SAE console. In the left-side navigation pane, choose Applications > Application List. Select the target region and namespace, and then click the name of the target application.
On the Basic Information page of the target application, click Modify Application Configurations.
Set application startup command
Image
Typically, you do not need to configure a startup command. When building the image, its ENTRYPOINT or CMD instruction in the Dockerfile already defines the container's startup command.
For example, the following command in the Dockerfile runs when the container starts.
ENTRYPOINT [nginx, '-g', 'daemon off;'] To override the startup command configured in the Dockerfile, follow these steps:
In the Startup Command section, select a script interpreter, such as >_ /bin/sh or >_ /bin/bash. Ensure the chosen interpreter exists in your image.
Configure the container's startup command. The format is as follows:
>_ /bin/sh
sh -c 'while true; do echo hello; sleep 10;done'>_ /bin/bash
bash -c 'while true; do echo hello; sleep 10;done'
If you are unfamiliar with the ENTRYPOINT and CMD configurations in the original Dockerfile, do not customize the startup command or its parameters. An invalid command will cause application creation to fail.
JAR package
To start and run a Java application, you must define a startup command and parameters, such as JVM parameters and GC policies.
SAE automatically compiles the uploaded JAR package into an image and runs the application as a container. During compilation, SAE sets a built-in startup command, parameters, and the JAR package path. You can use the SAE console to modify the default startup command and its parameters.
In the Startup Command Settings section, enter the required configurations. An example startup command is shown below.
The default startup command is $JAVA_HOME/bin/java $Options -jar $CATALINA_OPTS "$package_path" $args.
Parameter | Description |
Default Startup Command | The default startup command provided by SAE. |
Options Settings | Configure JVM parameters. For more information, see JVM parameter configuration notes, Tuning Java Virtual Machines, and JVM Tuning: How to Prepare Your Environment for Performance Tuning. To enable remote debugging for your application, add the command that corresponds to your JDK version.
The parameters are described as follows.
Important The startup commands for applications deployed from WAR packages and JAR packages are different. Do not use them interchangeably. The remote debugging command in this example applies to both deployment methods. |
args Settings | Configure the command to redirect standard output and standard error, such as |
WAR package
In the Startup Command Settings section, enter the required configurations. An example startup command is shown below.
The default startup command is CATALINA_OPTS="$CATALINA_OPTS $Options" catalina.sh run, where $Options is a placeholder for the JVM parameters that you specify in the Options Settings section. To avoid OOM, we recommend that you set the heap memory to a value less than the total instance memory and reserve 1 GB of space. For more information, see JVM configuration best practices.
Parameter | Description |
Default Startup Command | The default startup command provided by SAE. |
Options Settings | Configure JVM parameters. For more information, see JVM parameter configuration notes, Tuning Java Virtual Machines, and JVM Tuning: How to Prepare Your Environment for Performance Tuning. To enable remote debugging for your application, add the command that corresponds to your JDK version.
The parameters are described as follows.
Important The startup commands for applications deployed from WAR packages and JAR packages are different. Do not use them interchangeably. The remote debugging command in this example applies to both deployment methods. |
ZIP package
In the Startup Command section, select a script interpreter and configure the container's startup command.
>_ /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'