Introduction
Restarting applications in Terraform Enterprise is a straightforward process but requires careful planning and execution to minimise disruptions and ensure the continued smooth operation of your infrastructure. By following the steps outlined in this article and adhering to best practices, you can safely restart application as needed while maintaining the integrity and reliability of your TFE environment. This document is specifically designed for Terraform Enterprise deployed using replicated.
Use Case:
Restarting applications in Terraform Enterprise (TFE) might be necessary to apply changes, troubleshoot issues, or perform maintenance tasks. This article outlines the steps to safely restart applications within the TFE environment.
Not applicable for Terraform Enterprise Active-Active setup (replicated installation)
Pre-requisites:
- Access to the Terraform Enterprise host instance with appropriate permissions.
- Terraform Enterprise replicated mode of deployment (consolidated & non-consolidated).
- Basic understanding of docker/containers.
Solution:
- Check the application status. If running, then stop the application and wait for the status to show as stopped.
replicatedctl app status
replicatedctl app stop
replicatedctl app status ### Verify the status until the State is "stopped"
- Once application is stopped, stop the replicated services and check the status
systemctl stop replicated replicated-ui replicated-operator
systemctl status replicated replicated-ui replicated-operator
- Check the running container status. If there are some running containers, stop them using the commands below:
docker ps
docker stop $(docker ps -a -q) ### Stop all running containers.
- Reload the daemon, restart the docker and verify the docker status
systemctl daemon-reload
systemctl restart docker
systemctl status docker ### Verify the docker is up & running
- After docker is restarted, start the replicated services & check the status for errors (if any)
systemctl start replicated replicated-ui replicated-operator
systemctl status replicated replicated-ui replicated-operator
- Once replicated services are started without any errors, start the application and wait for application to start completely by monitoring the application status
replicatedctl app start
replicatedctl app status ### Verify the status until the State is "Started"
### with IsCancellable & IsTransitioning is "false"
### Final Output ######
[
{
"AppID": "1d1979cd76c843f05e0a8b407d0a5b62",
"Sequence": 751,
"PatchSequence": 0,
"State": "started",
"DesiredState": "started",
"Error": "",
"IsCancellable": false,
"IsTransitioning": false,
"LastModifiedAt": "2024-04-18T04:45:45.894804916Z"
}
]