gomog/start.sh

50 lines
1022 B
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Gomog 快速启动脚本
set -e
echo "======================================"
echo " Gomog Server 快速启动"
echo "======================================"
# 检查 Go 是否安装
if ! command -v go &> /dev/null; then
echo "错误:未找到 Go请先安装 Go 1.21+"
exit 1
fi
echo "✓ Go 版本:$(go version)"
# 进入项目目录
cd "$(dirname "$0")"
# 创建配置文件(如果不存在)
if [ ! -f config.yaml ]; then
echo "创建默认配置文件..."
cp config.yaml.example config.yaml
echo "✓ 配置文件已创建"
fi
# 下载依赖
echo "下载依赖..."
go mod download
go mod tidy
echo "✓ 依赖已下载"
# 构建
echo "构建项目..."
go build -v -o bin/gomog ./cmd/server
echo "✓ 构建完成"
# 显示配置
echo ""
echo "当前配置:"
cat config.yaml | grep -E "(http_addr|tcp_addr|type|dsn)" | sed 's/^/ /'
echo ""
# 启动服务器
echo "启动服务器..."
echo "======================================"
./bin/gomog -config config.yaml