CloudShell Colony supports running custom scripts as part of your application's lifecycle. There are 3 types of configurations that colony support – initialization, start and healthcheck.
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:
script: my-script.sh
healthcheck:
wait_for_ports: ALL
timeout: 180
You can reference three types of shell scripts that are executed in different stages of the application deployment and configuration process:
initialization:
configuration:
initialization:
script: init.sh
Field | Values | Description | Supports inputs? |
script | Name of the start script residing in the same folder as the application YAML on GitHub/BitBucket. |
(Optional) 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 package and configure the database connection string. The initialization phase will not count towards the health check timeout. Supported file types are: .sh, .ps or .ps1 |
No |
start:
configuration:
start:
script: start.sh
start:
command: >
dotnet /home/ubuntu/web/bin/Debug/netcoreapp2.0/publish/DSLibrary.dll
Field | Values | Description | Supports inputs? |
script | Name of the start script residing in the same folder as the application YAML on GitHub/BitBucket. |
(Optional) 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. |
No |
command |
Command or file path. For example: systemctl restart apache2.service |
(Optional) Command to run on the VM. |
No |
healthcheck:
configuration:
healthcheck:
wait_for_ports: ALL
timeout: 100
configuration:
healthcheck:
script: my-custom-healthcheck.sh
timeout: 1000
Field | Values | Description | Supports inputs? |
wait_for_ports |
|
CloudShell Colony already implements some basic checks which make sure that the application's internal ports, which are declared in the 'connectivity' section of the application YAML, are ready. This built-in capability is provided via the wait_for_all attribute, which specifies the ports (listed in the connectivity section) that should be checked. | Yes |
timeout | numeric |
(Optional) Specifies the time to wait (in seconds) for the health check to succeed. |
No |
script | Name of the healthcheck script residing in the same folder as the application YAML on GitHub/BitBucket. |
(Mandatory) Custom script to check a specific port. Omit to use Colony's the default healthcheck. If you need more flexibility, you can add your own health check shell scripts. For example, this script below should return a message similar to "connected to: hostname". It will return "0" to signal successful deployment while any other value would signal deployment failure. And is declared as follows:
|
No |
All script file references should be placed in the space's blueprint 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 scripts:
- 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. It usually starts or restarts an application process. In this example, 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.
Comments
0 comments
Please sign in to leave a comment.