OSS deployments download application source files from Object Storage Service (OSS) to your ECS instances and run shell scripts to start or stop the application.
How it works
-
If you deploy to an Auto Scaling (ESS) group, scaling activities are paused during deployment and resume automatically when the deployment finishes, regardless of the result.
-
Each deployment follows a stop-then-start sequence: the stop script runs first, then the start script.
-
Create and publish a deployment.
Specify the application's source file location in OSS, along with the start and stop scripts.
Create a release task, select a release mode, and publish the deployment to the target application group.
-
Automated deployment flow.
-
Retrieves the deployment configuration, including the OSS file location and the start and stop scripts.
-
Downloads the OSS file to the working directory on each instance.
-
Runs the stop script to stop the previous version of the application.
-
Runs the start script to launch the new version of the application.
-
Usage notes
-
Deployments are supported only on Linux instances.
-
The start and stop scripts must be shell scripts.
Procedure
-
Create an application and import your Elastic Compute Service (ECS) instances.
-
If you do not have an ECS instance, go to the ECS console - Custom Launch page to create a Linux ECS instance.
The following example scripts are for these images. If you use a different image, you must modify the scripts accordingly.
-
Go to the ECS console - Application management page and click Create from Existing Resources to create an application and an application group, and import the ECS instance into the application group.
-
-
Create an OSS deployment.
-
Download the official sample JAR package and upload it to OSS.
-
Go to the ECS console - Application management page. On the My Applications tab, click the name of your target application.
-
On the application details page, select the Deployment tab, and then click Create Deployment.
-
On the Create Deployment page, set Deployment Type to OSS File. Configure the parameters, and then click OK.
-
OSS file information: Specify the OSS bucket and the file path of the JAR package.
If the ECS instance and the OSS bucket are in the same region, you can select internal network download to increase the download speed.
-
Working directory: Set the execution directory for the start and stop scripts. The OSS file is automatically downloaded to this directory. Example:
/root/deploy. -
Alibaba Cloud Linux
start_application() { set -e yum install -y maven-3.5.4 java -jar ./sample-spring-1.0-SNAPSHOT.jar & } start_applicationUbuntu
start_application() { set -e apt update apt install -y maven java -jar ./sample-spring-1.0-SNAPSHOT.jar & } start_application -
### Stop the application (if any) stop_application() { PID=$(ps -ef | grep "sample-spring-1.0-SNAPSHOT.jar" | grep -v "grep" | awk '{print $2}') if [ -n "$PID" ]; then kill -9 $PID fi } stop_application
-
-
-
Go back to the deployment list, find the deployment that you created, and click Deploy. Select the target group and click OK to start the deployment.
-
Verify the result.
Navigate to the details page of the target instance. Click Connect and select Workbench. Follow the on-screen prompts to access the terminal.
-
Run the
curl http://localhost:8080/hellocommand. A response ofAlibaba Spring Sample!indicates a successful deployment.
Key parameters
|
Parameter |
Description |
|
OSS region |
The region of the source OSS bucket. |
|
OSS bucket |
The OSS bucket that contains the source file. |
|
OSS file |
The source file in the OSS bucket. |
|
OSS file version |
The version ID of the file. Required only when versioning is enabled for the bucket. Leave this field empty if versioning is disabled. |
|
Internal network download |
Select this option when the ECS instance and the OSS bucket are in the same region. |
|
Working directory |
The directory where the source file is downloaded and the start and stop scripts are run.
|
|
Application start script |
The shell script used to start the application. |
|
Application stop script |
The shell script to stop the application. For example, the following script stops a container named
|