Skip to content

[Chore/shell scripts] - 쉘 스크립트 작성#97

Merged
ekgns33 merged 2 commits intomainfrom
chore/shell-scripts
May 29, 2025
Merged

[Chore/shell scripts] - 쉘 스크립트 작성#97
ekgns33 merged 2 commits intomainfrom
chore/shell-scripts

Conversation

@ekgns33
Copy link
Contributor

@ekgns33 ekgns33 commented May 29, 2025

작업 내역

  • 배포, 도커용 스크립트 작성

Summary by CodeRabbit

  • New Features

    • Added scripts for managing the application lifecycle, including starting, stopping, and building the server.
    • Introduced a Docker management script for pulling images, starting, stopping, and viewing logs of containers.
    • Added a system resource monitoring script with color-coded output for CPU, memory, disk, network, application, and Docker status.
    • Provided a log cleanup script to automate log file maintenance.
  • Chores

    • Updated the build configuration to customize the generated executable JAR file name and version.

@ekgns33 ekgns33 requested a review from Copilot May 29, 2025 13:11
@ekgns33 ekgns33 self-assigned this May 29, 2025
@coderabbitai
Copy link

coderabbitai bot commented May 29, 2025

Walkthrough

Several new shell scripts were added to automate and manage various aspects of the "Runimo" application's lifecycle, including building, starting, stopping, resource monitoring, log cleanup, and Docker container management. Additionally, the Gradle build configuration was updated to specify custom naming for the Spring Boot jar artifact.

Changes

File(s) Change Summary
build.gradle Added bootJar block to set custom jar base name, file name, and version.
shell/clean-logs.sh New script to delete old and zero-byte log files from the logs directory.
shell/docker-start.sh New script to manage Docker container lifecycle for the "runimo" application.
shell/start-server.sh New script to build and run the Spring Boot application locally with logging and profile support.
shell/stop-server.sh New script to stop the "Runimo" service by killing its process.
shell/system-resource.sh New script to display system resource usage, process, network, and Docker status with color output.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant StartScript as start-server.sh
    participant Gradle
    participant JavaApp as Runimo.jar
    participant Logs

    User->>StartScript: ./start-server.sh build-start [profile]
    StartScript->>Gradle: gradle clean bootJar
    Gradle-->>StartScript: Build artifact (Runimo.jar)
    StartScript->>JavaApp: java -jar Runimo.jar --spring.profiles.active=[profile]
    JavaApp->>Logs: Write logs to log directory
Loading
sequenceDiagram
    participant User
    participant DockerScript as docker-start.sh
    participant Docker
    participant RunimoContainer

    User->>DockerScript: ./docker-start.sh start [profile]
    DockerScript->>Docker: Stop and remove existing container
    DockerScript->>Docker: Pull image from Docker Hub
    DockerScript->>Docker: Run new container with environment/profile
    Docker->>RunimoContainer: Start container
    User->>DockerScript: ./docker-start.sh logs
    DockerScript->>Docker: Show container logs
Loading

Poem

A hop, a skip, new scripts arrive,
To keep Runimo healthy and alive.
From Docker dance to logs swept clean,
And resource checks in vibrant green.
With jars now named just as they should,
This bunny’s work feels extra good!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between 884a3f2 and 7350a3a.

📒 Files selected for processing (6)
  • build.gradle (1 hunks)
  • shell/clean-logs.sh (1 hunks)
  • shell/docker-start.sh (1 hunks)
  • shell/start-server.sh (1 hunks)
  • shell/stop-server.sh (1 hunks)
  • shell/system-resource.sh (1 hunks)

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Join our Discord community for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ekgns33 ekgns33 merged commit 8a96db1 into main May 29, 2025
3 checks passed
@ekgns33 ekgns33 deleted the chore/shell-scripts branch May 29, 2025 13:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a set of shell scripts to support deployment, monitoring, and log management:

  • Introduces system-resource.sh for on-demand system metrics.
  • Provides start-server.sh/stop-server.sh for launching and terminating the Spring Boot JAR.
  • Adds docker-start.sh for container lifecycle operations and clean-logs.sh for log pruning.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
shell/system-resource.sh New script to print system, CPU, memory, disk, process, network, Spring app, and Docker statuses
shell/stop-server.sh Script to stop the Runimo application
shell/start-server.sh Script to build and start the Runimo application
shell/docker-start.sh Script to pull, start, restart, stop, and view logs of a Docker container
shell/clean-logs.sh Script to delete old and empty log files
Comments suppressed due to low confidence (2)

shell/stop-server.sh:6

  • Missing space before the closing bracket in the test expression, causing a syntax error. It should be: if [ -z "$pid" ]; then.
if [ -z "$pid"]; then

shell/stop-server.sh:10

  • The echo statement is malformed: process exit is outside the quotes. Wrap the entire message or separate arguments correctly, for example: echo "$SERVICE_NAME $pid closing... process exit".
echo "$SERVICE_NAME $pid closing..." process exit

Comment on lines +4 to +6
pid=`ps -elf | grep org.runimo.$SERVICE_NAME.jar`

if [ -z "$pid"]; then
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using grep on ps output can capture the grep process itself and returns full lines instead of just the PID. Consider using pgrep -f org.runimo.$SERVICE_NAME.jar to reliably retrieve the PID.

Suggested change
pid=`ps -elf | grep org.runimo.$SERVICE_NAME.jar`
if [ -z "$pid"]; then
pid=$(pgrep -f org.runimo.$SERVICE_NAME.jar)
if [ -z "$pid" ]; then

Copilot uses AI. Check for mistakes.

echo "프로필 $profile 로 애플리케이션 실행..."
nohup java -Xms512m -Xmx512m \
-jar -Dspring.profiles.active=$profile $JAR_FILE > "$LOG_DIR/$APP_NAME-$(date +%Y%m%d).log" 2>&1 &
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -jar flag must be followed directly by the JAR file path; JVM options like -Dspring.profiles.active should precede -jar. For example:

java -Xms512m -Xmx512m -Dspring.profiles.active=$profile -jar $JAR_FILE
Suggested change
-jar -Dspring.profiles.active=$profile $JAR_FILE > "$LOG_DIR/$APP_NAME-$(date +%Y%m%d).log" 2>&1 &
-Dspring.profiles.active=$profile -jar $JAR_FILE > "$LOG_DIR/$APP_NAME-$(date +%Y%m%d).log" 2>&1 &

Copilot uses AI. Check for mistakes.
*)
echo "사용법: $0 {build|start|build-start} [profile]"
echo " build: 애플리케이션 빌드"
echo " start [profile]: 특정 프로필로 애플리케이션 실행 (기본값: local)"
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage message states the default profile is local, but the script actually defaults to dev. Align the help text with the code or vice versa.

Suggested change
echo " start [profile]: 특정 프로필로 애플리케이션 실행 (기본값: local)"
echo " start [profile]: 특정 프로필로 애플리케이션 실행 (기본값: dev)"

Copilot uses AI. Check for mistakes.
print_memory_info() {
echo -e "${BLUE}=== 메모리 정보 ===${NC}"
if [[ "$OS_TYPE" == "Linux" ]]; then
read total used free shared buff cache available < <(free -m | awk 'NR==2{print $2, $3, $4, $5, $6, $7, $7}')
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AWK command prints field 7 twice, assigning both cache and available to the same value, and the script later echoes free instead of available for available memory. Adjust the AWK fields and variable assignments to correctly capture and display available memory.

Suggested change
read total used free shared buff cache available < <(free -m | awk 'NR==2{print $2, $3, $4, $5, $6, $7, $7}')
read total used free shared buff cache available < <(free -m | awk 'NR==2{print $2, $3, $4, $5, $6, $7}')

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,14 @@
#!/bin/bash

LOG_DIR="../logs"
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using a hardcoded relative path may lead to inconsistencies between scripts. Consider deriving the script's directory with dirname "$0" and constructing an absolute path to the logs folder for consistency.

Suggested change
LOG_DIR="../logs"
SCRIPT_DIR="$(dirname "$0")"
LOG_DIR="$(realpath "$SCRIPT_DIR/../logs")"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants