Deployment SOP
The deployment of the application is described in this section.
Resource Server
Login to the Resource Server using SSH.
Stop the application service using the below commands.
Run the following command to merge the latest changes from the remote repository to the local repository.
Rebuild the application using the below command.
Test run the application using the below command.
Start the application service using the below commands.
CMS Application
Login to the Resource Server using SSH.
Stop the application service using the below commands.
Check the status log if everything is running fine.
Run the following command to merge the latest changes from the remote repository to the local repository.
Rebuild the application using the below command.
Test run the application using the below command.
Start the application service using the below commands.
Check the status log if everything is running fine.
Frontend Application (Website)
Login to the Resource Server using SSH.
Stop the application service using the below commands.
Run the following command to merge the latest changes from the remote repository to the local repository.
Directory path may vary based on the Server configuration.
Rebuild the application using the below command.
Please note the resource server must be running before building the application.
Test run the application using the below command.
Start the application service using the below commands.
Check the status log if everything is running fine.
Notes
We have preconfigured all the required environment variables for the application in its individual service files. You can find the file in
/etc/systemd/systemdirectory.For Frontend application, we have preconfigured the environment variables in service files, and also there is a
.envfile in the root directory of the application is available for demo purpose and test runs.We recommend testing the deployments in a staging environment before deploying to production.
Readme.md files are included in the respective repositories of each project for Building Development and Production environments.
Please ensure merging any development branches to the master branch before deploying to production.
Note a resource server must be running before building both the Frontend and CMS applications.
Note the resource server has the
masterbranch for deployment, and CMS and Frontend have themainbranch for deployment.
Updates
Updates to the frameworks and libraries used in the project can be done using below commands.
These commands will update the dependencies and fix any vulnerabilities.
Rollback
Codebase is already available in the repository and can be rolled back to any previous commit you can use below commands to rollback.
Backup
We recommend taking regular backups of the database using the pg_dump utility.
Use the below command to back up the database.
In any case you need to restore the database, use the below commands.
Create new the database
psql -U postgres CREATE DATABASE xorsoyik_scdl_web_backup;Restore the database using the backup file
psql -U postgres -d xorsoyik_scdl_web_backup -f path_to_backup_directory/backup.sqlChange the database name environment variable in the
/etc/systemd/system/resource-server.servicefileDATABASE_NAME=xorsoyik_scdl_web_backupRestart the resource server
sudo systemctl restart resource-serverCheck the service status
sudo systemctl restart resource-serverIf everything is in place and working as expected, drop the old database.
psql -U postgres DROP DATABASE xorsoyik_scdl_web_backup;
Please make sure you have the backup file before deleting the database. Also, restoring old backup may cause data loss.
Files Backup
All the user-uploaded media files are stored in the /path-to-base-dir/app_uploads directory.
You can make a copy of the directory and store it as a backup in a different location.
Make sure to take incremental backups of the directory. As files may be uploaded to the directory at any time.
References
You can refer below links for more information about PostgreSQL and Systemd.