diff --git a/tools/help.sh b/tools/help.sh index 16d4d22..87ca209 100644 --- a/tools/help.sh +++ b/tools/help.sh @@ -2,29 +2,37 @@ set -e -# 复制Nginx、服务配置配置 -sudo cp -r ./tools/centos/* / +GREEN='\033[0;32m' +BLUE='\033[0;34m' +YELLOW='\033[0;33m' -# 复制后端服务到运行目录 -sudo rm -rf /data/wwwroot/server -sudo cp -r ./server /data/wwwroot/ +# shellcheck disable=SC2039 +echo -e "${BLUE}一些常用的命令脚本:${NC}" -# 创建游戏引擎服务端运行目录 -if [ ! -d "/data/wwwroot/game" ]; then - mkdir -p /data/wwwroot/game -fi +echo -e "${GREEN}查看所有服务状态${NC}" +# shellcheck disable=SC2039 +echo -e "${GREEN}sudo systemctl status server.service game.service${NC}" -# 编译后端服务 -cd /data/wwwroot/server/ -/usr/local/go/bin/go env -w GOSUMDB=off -export GO111MODULE=on && export GOPROXY=https://goproxy.io && /usr/local/go/bin/go build main.go +# shellcheck disable=SC2039 +echo -e "${GREEN}重启后端服务${NC}" +# shellcheck disable=SC2039 +echo -e "${GREEN}sudo systemctl restart server.service${NC}" +# shellcheck disable=SC2039 +echo -e "${GREEN}重启游戏服务器${NC}" +# shellcheck disable=SC2039 +echo -e "${GREEN}sudo systemctl restart game.service${NC}" -# 重启Nginx服务 -sudo systemctl restart nginx.service +# shellcheck disable=SC2039 +echo -e "${GREEN}监听后端服务实时日志${NC}" +# shellcheck disable=SC2039 +echo -e "${GREEN}sudo journalctl -fu server.service${NC}" +# shellcheck disable=SC2039 +echo -e "${GREEN}监听游戏服务器实时日志${NC}" +# shellcheck disable=SC2039 +echo -e "${GREEN}sudo journalctl -fu game.service${NC}" +# shellcheck disable=SC2039 -# 重启后端服务和游戏服务 -sudo systemctl daemon-reload -sudo systemctl enable server.service -sudo systemctl restart server.service -sudo systemctl enable game.service -sudo systemctl restart game.service \ No newline at end of file +echo -e "${GREEN}重启Nginx服务${NC}" +# shellcheck disable=SC2039 +echo -e "${GREEN}sudo systemctl restart nginx.service${NC}" +# shellcheck disable=SC2039 \ No newline at end of file diff --git a/tools/init.sh b/tools/init.sh index 87ca209..16d4d22 100755 --- a/tools/init.sh +++ b/tools/init.sh @@ -2,37 +2,29 @@ set -e -GREEN='\033[0;32m' -BLUE='\033[0;34m' -YELLOW='\033[0;33m' +# 复制Nginx、服务配置配置 +sudo cp -r ./tools/centos/* / -# shellcheck disable=SC2039 -echo -e "${BLUE}一些常用的命令脚本:${NC}" +# 复制后端服务到运行目录 +sudo rm -rf /data/wwwroot/server +sudo cp -r ./server /data/wwwroot/ -echo -e "${GREEN}查看所有服务状态${NC}" -# shellcheck disable=SC2039 -echo -e "${GREEN}sudo systemctl status server.service game.service${NC}" +# 创建游戏引擎服务端运行目录 +if [ ! -d "/data/wwwroot/game" ]; then + mkdir -p /data/wwwroot/game +fi -# shellcheck disable=SC2039 -echo -e "${GREEN}重启后端服务${NC}" -# shellcheck disable=SC2039 -echo -e "${GREEN}sudo systemctl restart server.service${NC}" -# shellcheck disable=SC2039 -echo -e "${GREEN}重启游戏服务器${NC}" -# shellcheck disable=SC2039 -echo -e "${GREEN}sudo systemctl restart game.service${NC}" +# 编译后端服务 +cd /data/wwwroot/server/ +/usr/local/go/bin/go env -w GOSUMDB=off +export GO111MODULE=on && export GOPROXY=https://goproxy.io && /usr/local/go/bin/go build main.go -# shellcheck disable=SC2039 -echo -e "${GREEN}监听后端服务实时日志${NC}" -# shellcheck disable=SC2039 -echo -e "${GREEN}sudo journalctl -fu server.service${NC}" -# shellcheck disable=SC2039 -echo -e "${GREEN}监听游戏服务器实时日志${NC}" -# shellcheck disable=SC2039 -echo -e "${GREEN}sudo journalctl -fu game.service${NC}" -# shellcheck disable=SC2039 +# 重启Nginx服务 +sudo systemctl restart nginx.service -echo -e "${GREEN}重启Nginx服务${NC}" -# shellcheck disable=SC2039 -echo -e "${GREEN}sudo systemctl restart nginx.service${NC}" -# shellcheck disable=SC2039 \ No newline at end of file +# 重启后端服务和游戏服务 +sudo systemctl daemon-reload +sudo systemctl enable server.service +sudo systemctl restart server.service +sudo systemctl enable game.service +sudo systemctl restart game.service \ No newline at end of file diff --git a/wiki/course/0002.md b/wiki/course/0002.md index f2a3243..d017321 100644 --- a/wiki/course/0002.md +++ b/wiki/course/0002.md @@ -1,158 +1,3 @@ -## 第一课 +## 第二课 -> 第一课时操作引导文档。 - -### 一、游戏资源下载 - -> 1、访问:[GitHub](https://www.github.com) - -> 2、下载安装Git:[Git](https://git-scm.com) - -````shell -# 生成GitHub SSH KEY -ssh-keygen -t rsa -C "你的GitHub登录账号" -```` - -```shell -git config -global user.name "你的GitHub用户名" -git config -global user.email "你的GitHub登录账号" -``` - -````shell -# 获取生成的GitHub SSH KEY -C:\Users\admin/.ssh/id_rsa.pub -```` - -```shell -# 下载游戏源码 -git clone --depth=1 git@github.com:makeryangcom/Engine2D.git -``` - -### 二、虚拟机的安装和配置 - -> 1、CentOS系统镜像下载地址:[CentOS-8.5.2111-x86_64-dvd1.iso](https://mirrors.aliyun.com/centos/8/isos/x86_64/CentOS-8.5.2111-x86_64-dvd1.iso) - -> 2、切换到root用户,密码为`root` - -```shell -su -``` - -> 3、修改SSH配置,防止后续SSH远程登录时因连接超时自动断开 - -```shell -vim /etc/ssh/sshd_config -``` - -> 4、获取虚拟机服务器内网IP地址 - -```shell -ifconfig -``` - -> 5、在本地电脑的命令行工具中通过SSH远程登录到虚拟机服务器 - -```shell -ssh root@服务器内网IP地址 -``` - -> 6、更新软件源 - -```shell -sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* -sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* -# 设置阿里云软件源 -wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo -# 清理缓存 -yum clean all -yum makecache -``` - -> 7、游戏资源下载 - -````shell -# 安装git -yum install -y git -```` - -````shell -# 生成GitHub SSH KEY -ssh-keygen -t rsa -C "你的GitHub登录账号" -```` - -````shell -# 获取生成的GitHub SSH KEY -cat /root/.ssh/id_rsa.pub -```` - -```shell -git config --global user.name "你的GitHub用户名" -git config --global user.email "你的GitHub登录账号" -``` - -```shell -cd /opt -# 下载游戏源码 -git clone --depth=1 git@github.com:makeryangcom/Engine2D.git -``` - -> 8、自动化部署 - -```shell -cd /opt/Engine2D -sudo ./tools/init.sh -``` - -```shell -# 取消CRYPTO_POLICY=的注释 -vim /etc/sysconfig/sshd -# MySQL数据库远程连接配置 -vim /etc/ssh/sshd_config -# 在最后添加下面的配置 -Ciphers aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc -KexAlgorithms diffie-hellman-group1-sha1 -# 重启服务 -sudo systemctl restart sshd -``` - -```shell -cd /opt/Engine2D -sudo ./tools/update.sh -``` - -> 9、本地解析服务器域名 - -```shell -C:\Windows\System32\drivers\etc -``` - -> 10、日常维护使用的命令 - -``` bash -# 监听后端服务日志 -sudo journalctl -fu server.service -# 监听游戏服务器日志 -sudo journalctl -fu game.service - -# 常用维护命令-重启Nginx服务 -sudo systemctl restart nginx.service -# 常用维护命令-停止Nginx服务 -sudo systemctl stop nginx.service -# 常用维护命令-启动Nginx服务 -sudo systemctl start nginx.service - -# 查看后端服务、游戏服务器状态 -sudo systemctl status server.service game.service - -# 停止、重启后端服务 -sudo systemctl stop|restart server.service -# 停止、重启游戏服务器 -sudo systemctl stop|restart game.service -``` - -> 11、其他配置 - -```shell -Host 0.0.0.0 -KexAlgorithms +diffie-hellman-group1-sha1 -``` \ No newline at end of file +> 第一课时操作引导文档。 \ No newline at end of file