Web+ allows you to manage environments based on your business needs by customizing start commands, stop commands, and lifecycle hooks.

Configure commands or lifecycle hooks on the Configurations page

You can configure commands or lifecycle hooks when creating a new environment and when changing the configurations of a running environment.

Configure commands or lifecycle hooks when creating a new application and environment

  1. Log on to the Web+ console.
  2. On the Overview page, click Create in the upper-right corner of the Last Updated Environments section. Follow the instructions to configure the required settings in the Basic Information and Environment Information steps. Then, configure the required settings in the Configurations step.
  3. In the Configurations step, select Custom for the Pre-defined Configuration setting.
  4. On the list of displayed settings, click Commands or Lifecycle Hooks in the Applications section and configure the required settings.
  5. Click Creation Complete to create a new environment.

Configure commands or lifecycle hooks when updating anEnvironment environment

  1. Log on to the Web+ console.
  2. On the Overview page, click View All in the upper-right corner of the Last Updated Environments section.
  3. On the Applications and Environments page, click the ID of an application for which you want to create a new environment.
  4. On the Application Details page, click Create Environment in the upper-right corner, configure the required settings in the Environment Information step, and then go to the Configuration step.
  5. In the Configurations step, select Custom for the Pre-defined Configuration setting.
  6. On the list of Environments
  1. section.
  2. On the Applications and Environments page, click the > icon next to the name of an application to show a list of linked environments.
  3. Click the name of an environment to go to the Overview tab of the Environment Details page.
  4. In the left-side navigation pane, click Configurations to go to the Configurations page.
  5. On the Configurations page, click Commands or Lifecycle Hooks in the Applications section and configure the required settings.
  6. Click Change Configuration to update the environment.

Commands

In most cases, Web+ predefines default stop and start commands for each type of technology stacks. Web+ uses systemd to manage user processes by default.
Note
  • A start command must run as a frontend application. When the start command is complete, the backend service that corresponds to the command is also stopped.
  • We recommend that you always include the systemctl stop wpweb snippet in a stop command to ensure that a service can be terminated as expected. You can add custom statements before and after the snippet to complement a stop command.
  • The working directory of a start command is the same as the local directory that stores the deployment package of an application to which the start command applies.
  • You must use the admin credential to run a start command.
  • If a deployment package includes Procfile, the specified start command that applies to an application built by the deployment package will not take effect.

Lifecycle hooks

When Web+ performs update actions on instances, specific lifecycle hooks will be triggered. You can specify custom commands or scripts for these lifecycle hooks to perform specific actions. These actions include modifying configuration files, registering or deregistering services, sending notifications, and downloading files.

  • PostPrepareEnv: After a environment is initialized, the lifecycle hook is executed. The lifecycle hook only runs once for each instance. You cannot read environment variables while the lifecycle hook is running.
  • PreInstallStack: Before you install or change fundamental software that is included in a technology stack, the lifecycle hook is executed. You cannot read environment variables while the lifecycle hook is running.
  • PostInstallStack: After you install or change fundamental software that is included in a technology stack, the lifecycle hook is executed. You cannot read environment variables while the lifecycle hook is running.
  • PrePrepareApp: Before an update occurs on an application such as a change in deployment package version, the lifecycle hook is executed. You cannot read environment variables while the lifecycle hook is running.
  • PostPrepareApp: Before an update occurs on an application such as a change in deployment package version, the lifecycle hook is executed. You can use environment variables while the lifecycle hook is running.
  • PreStart: Before an application is started, the lifecycle hook is executed. You can use environment variables while the lifecycle hook is running.
  • PostStart After an application is started, the lifecycle hook is executed. You can use environment variables while the lifecycle hook is running.
  • PreStop: Before an application is stopped, the lifecycle hook is executed. You can use environment variables when the lifecycle hook is running.
  • PostStop: After an application is stopped, the lifecycle hook is executed. You can use environment variables while the lifecycle hook is running.
Note
  • You must use root permissions to execute lifecycle hooks.
  • A failed execution of a lifecycle hook results in a failed update and the termination of the update. You can avoid update errors regardless of whether the execution result of a lifecycle hook is successful or fails. We recommend that you add the ;exit 0 snippet at the end of a lifecycle hook command to ensure the successful execution of a lifecycle hook.
  • You can use environment variables in some types of lifecycle hooks. For more information about available environment variables, see Environment variables.
  • A lifecycle hook must be completed within two minutes. Otherwise, an update fails and is terminated. If a task requires more than two minutes to complete, we recommend that you run a script at the backend to complete the task.
  • The working directory of lifecycle hooks is /opt/webplus/data/envdata/wproot/. You can use the cd command to move to the specified directory.
  • We recommend that you specify the absolute path of an executable file that points to a command or script in a lifecycle hook.