Refactor deployment script to prevent unnecessary Jetty downtime#2066
Conversation
WalkthroughThe deployment script has been updated to improve robustness during the web application deployment process. The changes introduce enhanced error handling using Changes
Sequence Diagram(s)sequenceDiagram
participant Script as Deployment Script
participant Repository as External Repository
participant Server as Jetty Server
Script->>Script: Check for VERSION variable
alt VERSION provided
Script->>Repository: Download WAR file with wget (with retries & timeout)
alt Download successful
Script->>Script: Move WAR file from temporary to target location
Script->>Server: Stop Jetty
Script->>Server: Deploy new WAR file
Script->>Server: Start Jetty
Script->>Script: Log success message
else Download failed
Script->>Script: Print error and exit
end
else VERSION missing
Script->>Script: Print error message and exit
end
Possibly related PRs
Suggested reviewers
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2066 +/- ##
=========================================
Coverage 15.19% 15.19%
Complexity 404 404
=========================================
Files 243 243
Lines 6672 6672
Branches 747 747
=========================================
Hits 1014 1014
Misses 5608 5608
Partials 50 50 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/main/config/centos-stream-9/~/.elimu-ai/deploy-webapp.sh (3)
28-29: Conditional shutdown of Jetty
Stopping Jetty only after a successful WAR file download is a significant improvement. However, consider implementing a trap or further error handling in the subsequent deployment steps to ensure that, if any later command fails, Jetty can be restarted to avoid prolonged downtime.
31-32: Deployment step for moving the WAR file
Themv -fcommand clearly moves the downloaded WAR file to its target location. Note that if this step fails after Jetty has been stopped, the system may remain in an unstable state. You might want to add error handling (or a recovery trap) to restart Jetty if the move fails.
34-35: Restarting Jetty and service confirmation
The script properly restarts Jetty after deploying the new WAR file. As an enhancement, you could add a service status check post-restart to verify that Jetty has started correctly.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/config/centos-stream-9/~/.elimu-ai/deploy-webapp.sh(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: build (macos-latest, 17)
- GitHub Check: build (windows-latest, 21)
- GitHub Check: build (windows-latest, 17)
- GitHub Check: build (ubuntu-latest, 17)
- GitHub Check: build (ubuntu-latest, 21)
- GitHub Check: build (macos-latest, 21)
- GitHub Check: test_rest_ENG
- GitHub Check: test_ui_ENG
🔇 Additional comments (4)
src/main/config/centos-stream-9/~/.elimu-ai/deploy-webapp.sh (4)
3-4: Enhancement withset -e
The addition ofset -eensures the script will immediately exit on any command failure, which is critical for a robust deployment process.
7-10: Validation for required VERSION parameter
The check for an emptyVERSIONvariable is well implemented, ensuring that the script only proceeds if a valid version is provided. This prevents potential downstream errors.
14-16: Clear variable definitions for file paths and URL
DefiningWAR_FILE_URL,TMP_WAR_FILE, andTARGET_WAR_FILEin this segment improves maintainability and readability. It makes future changes easier if the download location or target directory ever need updates.
21-24: Robust error handling during WAR file download
The use ofwgetwith retries and timeout settings along with error checking ensures that the script exits before taking further action if the download fails. This avoids stopping Jetty unnecessarily.
jo-elimu
left a comment
There was a problem hiding this comment.
@ideal3147 Tested the changes, and it worked perfectly 👍
# ~/.elimu-ai/deploy-webapp.sh 2.5.41
VERSION: 2.5.41
Downloading WAR file from https://jitpack.io/com/github/elimu-ai/webapp/webapp-2.5.41/webapp-webapp-2.5.41.war
--2025-03-16 06:37:03-- https://jitpack.io/com/github/elimu-ai/webapp/webapp-2.5.41/webapp-webapp-2.5.41.war
Resolving jitpack.io (jitpack.io)... 2606:4700:20::ac43:4881, 2606:4700:20::681a:963, 2606:4700:20::681a:863, ...
Connecting to jitpack.io (jitpack.io)|2606:4700:20::ac43:4881|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 88340052 (84M) [application/zip]
Saving to: ‘/tmp/webapp-2.5.41.war’
/tmp/webapp-2.5.41.war 100%[============================================================================>] 84.25M 31.4MB/s in 2.7s
Last-modified header invalid -- time-stamp ignored.
2025-03-16 06:37:07 (31.4 MB/s) - ‘/tmp/webapp-2.5.41.war’ saved [88340052/88340052]
Download completed successfully.
Stopping Jetty...
Deploying new WAR file...
Starting Jetty...
Deployment completed successfully.
Issue Number
.wardownload completes #2040Purpose
Technical Details
Testing Instructions