Files
web-giao-ban-go/start.sh
T

29 lines
858 B
Bash
Executable File

#!/bin/bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$DIR"
# Check if systemd service exists and active
if systemctl is-enabled --quiet web-giao-ban-go 2>/dev/null || systemctl is-active --quiet web-giao-ban-go 2>/dev/null; then
echo "Khởi động qua systemd service: web-giao-ban-go..."
sudo systemctl start web-giao-ban-go
sudo systemctl status web-giao-ban-go --no-pager
exit 0
fi
# Fallback to direct process
PID=$(pgrep -f "$DIR/web-giao-ban" || true)
if [ -n "$PID" ]; then
echo "Ứng dụng Go đang chạy với PID: $PID"
exit 0
fi
echo "Đang khởi động web-giao-ban nền..."
nohup ./web-giao-ban > /dev/null 2>&1 &
sleep 1
PID=$(pgrep -f "$DIR/web-giao-ban" || true)
if [ -n "$PID" ]; then
echo "Khởi động thành công! PID: $PID"
else
echo "Khởi động thất bại, kiểm tra logs/app.log"
fi