doc-exports/docs/cce/umn/cce_bestpractice_0007.html
Dong, Qiu Jian 3d9cca138b CCE UMN: Added the support of the OS for features and cluster versions.
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com>
Co-authored-by: Dong, Qiu Jian <qiujiandong1@huawei.com>
Co-committed-by: Dong, Qiu Jian <qiujiandong1@huawei.com>
2023-06-20 14:52:27 +00:00

3.7 KiB
Raw Blame History

Compiling a Startup Script

During application containerization, you need to prepare a startup script. The method of compiling this script is the same as that of compiling a shell script. The startup script is used to:

  • Start up the software on which the application depends.
  • Set the configurations that need to be changed as the environment variables.

Startup scripts vary according to applications. You need to compile the script based on your service requirements.

Procedure

  1. Log in as user root to the device running Docker.
  2. Run the following commands to create the directory where the application is to be stored:

    mkdir apptest

    cd apptest

  3. Compile a script file. The name and content of the script file vary according to applications. You need to compile the script file based on your application. The following example is only for your reference.

    vi start_tomcat_and_mongo.sh
    #!/bin/bash
    # Load system environment variables.
    source  /etc/profile
    # Start MongoDB. The data is stored in /usr/local/mongodb/data.
    ./usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/logs --port=27017 fork
    # These three script commands indicate that the contents related to the MySQL database in the environment variables are written into the configuration file when Docker is started.
    sed -i "s|mysql://.*/awcp_crmtile|mysql://$MYSQL_URL/$MYSQL_DB|g" /root/apache-tomcat-7.0.82/webapps/awcp/WEB-INF/classes/conf/jdbc.properties
    sed -i "s|username=.*|username=$MYSQL_USER|g" /root/apache-tomcat-7.0.82/webapps/awcp/WEB-INF/classes/conf/jdbc.properties
    sed -i "s|password=.*|password=$MYSQL_PASSWORD|g" /root/apache-tomcat-7.0.82/webapps/awcp/WEB-INF/classes/conf/jdbc.properties
    # Start Tomcat.
    bash /root/apache-tomcat-7.0.82/bin/catalina.sh run