CloudShell Colony supports running application scripts and commands to be used in configuring, launching and checking the health status of your application. Reference to an application script should be added to your applications' YAML file under the Configuration section.
configuration: initialization: script: acme-dashboard-install.sh start: command: > dotnet /home/ubuntu/web/bin/Debug/netcoreapp2.0/publish/DSLibrary.dll healthcheck: wait_for_ports: ALL timeout: 180
You can reference to two types of scripts which are executed in different stages of the application deployment and configuration process:
- initialization: This script's main function is to configure everything needed to run the application, including installing dependencies and downloading packages. For example, a typical initialization script might install a required software packages and configure the database connection string. The initialization phase will not count towards the health check timeout.
- start: This is the actual command that will run the application. Colony will begin its health check process when this command runs. An example start script can be running the NginX process when starting a web server. You can either specify the command directly, as seen in the above example or reference a script.
- healthcheck: CloudShell Colony already implements some basic checks which make sure that certain ports are ready. You can specify a specific port to check or just set the value as 'ALL' in which case all ports declared under 'connectivity' will be checked. The timeout property controls how much time (in seconds) Colony should wait for the health check to succeed.
All script files references should be placed in your blueprint's repository, right next to the application's YAML file. For example:
As an example, let's review the WordPress application (Wordpress.yaml file) in CloudShell Colony's sample blueprint repository. The application uses a clean Ubuntu Linux image. Therefore, to install WordPress we need to run additional scripts after the instance is up. The scripts are included in the /wordpress folder, and we declare them in the wordpress.yaml file as follows:
configuration initialization: script: wordpress.sh start: script: wordpress-start.sh;
The wordpress.yaml file includes the following scrips:
- wordpress.sh: This is an initialization script, which takes the clean Ubuntu installation and installs everything needed to run WordPress. The script consists of the following steps:
- Update the Linux package manager.
- Install Apache web server.
- Install PHP and the required PHP modules, in order to run WordPress.
- Download the latest version of Wordpress and install it.
- Configure the database access by modifying the wp-config.php files.
- wordpress-start.sh: This script runs only after the Initialization script completes and it usually start or restart an application process. In this examples, this script restarts the Apache Web Server.
NOTE: CloudShell Colony does not expect the Start script to complete. It is expecting that the Start script might be the running application process.
Best Practices for Writing Application Scripts
To support you in creating reusable applications and to provide you with a self-service experience, CloudShell Colony includes some important features such as Local DNS service and user input parameters. To learn more about these features, see Working with Parameters and Best Practices for Writing Application Scripts.