Remote Deployment Process - Java

Remote Deployment Process - Java


Deployment Process

  1. Determine if a valid argument has been passed in
    1. Only continue if downloadOnly, postDownload, fullDeployment, handleSuccess, checkHash, verifyApplications passed through.
  2. Lock file to stop deployment from running more than once
      1. Create deployment_lock_file.txt if it does not exist.
      2. Create lock on file.
      3. If lock is already held, log an error message and stop the deployment.
  3. Create Directories
      1. If needed, create directories for applied and backup to store previous war files and copies of downloaded files.
      2. Create temporary directory to store downloaded files.
  4. Figure out which files/scripts to download
      1. Download manifest.xml file
      2. If no manifest.xml file downloaded, log an error message and stop the deployment.
      3. Read manifest file to determine what server to download from and create DownloadServer object
      4. Read manifest file to determine what application files/SQL scripts to be downloaded. Create list of ApplicationFile and SqlScript objects to store information about the files.
  5. Confirm manifest file has not been run
    1. Look for row in Deployment Files table with same file name and sha2sum as the following:
      1. manifest.xml file
      2. All files in ApplicationFile list
      3. All files in SqlScript list
    2. If there is a match of sh2sum values, log an error message and stop the deployment.
  6. Download files from server and store on local server in temporary location
    1. Use jsch to download files via SFTP
      1. Use password protected private key for authentication
    2. For each object in the ApplicationFile list and SqlScript list, download the file.
  7. Confirm that war files are complete (no partial downloads, no missing files)
      1. Use sha2 checksums.
      2. Grab expected values from applicable ApplicationFile or SqlScript object.
      3. If sh2sum values do not match, log an error message and stop the deployment.
  8. Back-up database
      1. Run existing dbbackup.sh script using process builder.
      2. If exit value from process is not 0, log exit code and stop the deployment.
  9. Run SQL scripts
    1. Iterate through list of SqlScript.
      1. Open each file and create string with contents.
      2. Execute statement using username and password provided in the SqlScript object.
    2. If sql scripts are unable to run, log an error message and stop the deployment.
  10. Move current war files to archive directory
      1. Iterate through the list of ApplicationFile
        1. Find the war file in the webapps directory that has the same name.
        2. Utilize FileUtils.copyFile function to move current war files from Tomcat webapp directory to archive directory
  11. Delete war files/application directory
      1. Iterate through the list of ApplicationFile
        1. Remove war file and directory with the same name as the file name under webapps. Remove files under work directory with directory of same name.
  12. Place new war files from temporary location to tomcat directory
      1. Iterate through the list of ApplicationFile
        1. Utilize FileUtils.copyFile function to move file name in ApplicationFile to Tomcat webapp directory
  13. Restart Tomcat
    1. Run ‘service tomcat restart’ command using process builder.
  14. Verify Applications
      1. Run tests to check if touchscreen and back office applications are up.
      2. Pull version from ApplicationFile object to check that the correct version of the application is up.
      3. This process will run up to 10 times with an increased amount of wait, additional five seconds, between each unsuccessful try.
  15. Deployment Clean-Up
      1. Create tar.gz file with contents of download directory
      2. Remove tar.gz files older than 3 months old
      3. Remove log files older than 3 months old
      4. Remove temporary download directory
      5. Create row in Deployment File table for the following:
        1. manifest.xml
        2. All files in ApplicationFile List
        3. All files in SqlScript list
  16. Release file lock
    1. Release lock on deployment_lock_file.txt so the next deployment can run.

Process Documentation

  1. Log deployment process
      1. Use log4j
        1. Log files will be stored in their own log directory located in the home directory of the deployment user.
      2. Send information to webservice on fcadmin (or different server later on)
        1. Information will be stored in an event logger table and include information on serial number, community, stage, result, message, and date.
  2. Report results back to FullCount
      1. Send information to webservice on fcadmin
        1. Information will be stored in an event logger table and include information on serial number, community, stage, result, message, and date.

Error Handling

  1. Handle situation where war files/SQL scripts cannot be downloaded
  2. Handle situation where war files/SQL scripts are partially downloaded
  3. Handle situation where SQL script is unable to execute
  4. Handle situation where war files/SQL scripts take much longer than expected to download.
      1. Set some kind of upper limit for how long a download can take.
      2. If download is estimated to finish in 3 days, that is effectively a failure, so we should kill it and try again.
  5. Handle situation where war files/SQL scripts cannot be saved (i.e. no disk space).
  6. Handle situation where SQL script is taking longer than expected to execute.
      1. Set some kind of upper limit for how long a SQL script can take to execute.
  7. Handle situation where database backup fails.
  8. Handle situation where archiving old WAR files fails.

 

Full Deployment

Download Only

Check Hash

Post Download

Post SQL Scripts

Verify Applications

Handle Success

Determine Valid Argument

X

X

X

X

X

X

X

Lock File

X

X

X

X

X

X

X

Create Directories

X

X

X

X

X

X

X

Load Manifest File

X

X

X

X

X

X

X

Confirm Deployment Not Run

X

X

X

X

X

 

X

Download Deployment Files

X

X

 

 

 

 

 

Check Hash Values

X

 

X

X

 

 

 

Back-Up Database

X

 

 

X

 

 

 

Run SQL Scripts

X

 

 

X

 

 

 

Move Files For Deployment

X

 

 

X

X

 

 

Restart Tomcat

X

 

 

X

X

 

 

Verify Applications Up

X

 

 

X

X

X

X

Deployment Clean-Up

X

 

 

X

X

 

X

Release Lock File

X

X

X

X

X

X

X

Resources Section

This is being used to download files from our central server to the remote server

This is being used to verify that the applications are up

This is being used to create an archive with all the download files, specifically the TarArchive information.

This is being used to move files around on the server.

 


    • Related Articles

    • Run Remote Deployment Process - Java

      Remote Server Configuration This has already been completed for all existing remote servers. Java 1.8 installed Tomcat located at /srv/tomcat XE database installed and running with fc_obj_owner user Directory /home/deployment exists Database backup ...
    • Overview of Deployment Process for Remote Servers

      Overview of Deployment Process for Remote Servers Introduction The process for updating the Touchscreen and Back Office applications is known as the deployment process. The deployment process is only used for updating applications and databases on ...
    • Post Central Deployment Tasks

      Post Central Deployment Tasks Objectives Complete necessary post-deployment tasks Prerequisites Access to Redmine Access to production database Access to fcadmin Access to deployment test server Instructions Send release docs Release docs are located ...
    • Remote Server Decommission Process

      Remote Server Decommission Process The purpose of this document is to track the process for decommissioning a FullCount remote server as part of the transition for the client to be centrally hosted or if the client is leaving FullCount. The first ...
    • Central Deployment Process

      Run SQL scripts in http://sourcecontrol.fullcount.net/repos/internal/trunk/at-fullcount-model/src/main/resources/sql/nextDeploy Pause TeamCity test for fullcount-uptime-production-overnight. Download release war file from archiva for all ...