-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstatus-instance.sh
More file actions
executable file
·66 lines (51 loc) · 1.83 KB
/
Copy pathstatus-instance.sh
File metadata and controls
executable file
·66 lines (51 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# =============================================================================
# USAGE: ./status-instance.sh <instance-name>
# EXAMPLE: ./status-instance.sh instance1
# =============================================================================
# Check if instance name is provided
if [ $# -eq 0 ]; then
echo "Usage: $0 <instance-name>"
echo "Example: $0 instance1"
exit 1
fi
INSTANCE_NAME="$1"
# Colors for output
BLUE='\033[0;34m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
print_status() {
echo -e "${BLUE}[${INSTANCE_NAME}]${NC} $1"
}
print_success() {
echo -e "${GREEN}[${INSTANCE_NAME}]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[${INSTANCE_NAME}]${NC} $1"
}
print_error() {
echo -e "${RED}[${INSTANCE_NAME}]${NC} $1"
}
# Check if PM2 is installed
if ! command -v pm2 &> /dev/null; then
print_error "PM2 is not installed."
exit 1
fi
print_status "Status for instance: $INSTANCE_NAME"
echo ""
# Show detailed status for all processes in this instance
pm2 list | grep "${INSTANCE_NAME}" || {
print_warning "No processes found for instance '$INSTANCE_NAME'"
echo "Use './start-instance.sh env.${INSTANCE_NAME}' to start this instance"
}
echo ""
print_status "Process details:"
pm2 show "${INSTANCE_NAME}-backend" 2>/dev/null | grep -E "(name|status|pm2_env|pm_cwd)" || print_warning "Backend not running"
echo ""
# pm2 show "${INSTANCE_NAME}-agent-service" 2>/dev/null | grep -E "(name|status|pm2_env|pm_cwd)" || print_warning "Agent Service not running"
# echo ""
pm2 show "${INSTANCE_NAME}-agent-service-api" 2>/dev/null | grep -E "(name|status|pm2_env|pm_cwd)" || print_warning "Agent Service API not running"
echo ""
pm2 show "${INSTANCE_NAME}-frontend" 2>/dev/null | grep -E "(name|status|pm2_env|pm_cwd)" || print_warning "Frontend not running"