Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpp12.2.0-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eazy-template
cpp12.2.0-template
Commits
35714658
Commit
35714658
authored
Sep 17, 2025
by
xiezhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix makefile
parent
764765c6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
106 deletions
+7
-106
Makefile
Makefile
+2
-77
README.md
README.md
+5
-29
No files found.
Makefile
View file @
35714658
...
@@ -49,11 +49,7 @@ run: install
...
@@ -49,11 +49,7 @@ run: install
# 停止命令
# 停止命令
.PHONY
:
stop
.PHONY
:
stop
stop
:
kill
stop
:
# 强制杀死所有相关C++进程
.PHONY
:
kill
kill
:
@
echo
"正在查找并杀死所有相关的C++进程..."
@
echo
"正在查找并杀死所有相关的C++进程..."
@
PIDS
=
$$
(
ps aux |
grep
-E
"hello_world|
$(APP_NAME)
"
|
grep
-v
grep
|
awk
'{print $$2}'
)
;
\
@
PIDS
=
$$
(
ps aux |
grep
-E
"hello_world|
$(APP_NAME)
"
|
grep
-v
grep
|
awk
'{print $$2}'
)
;
\
if
[
-n
"
$$
PIDS"
]
;
then
\
if
[
-n
"
$$
PIDS"
]
;
then
\
...
@@ -68,75 +64,4 @@ kill:
...
@@ -68,75 +64,4 @@ kill:
echo
"未找到相关的C++进程"
;
\
echo
"未找到相关的C++进程"
;
\
fi
fi
@
rm
-f
$(PID_FILE)
@
rm
-f
$(PID_FILE)
@
echo
"✅ 强制停止操作完成"
@
echo
"✅ 停止操作完成"
# 重启命令
.PHONY
:
restart
restart
:
stop run
# 查看状态
.PHONY
:
status
status
:
@
if
[
-f
"
$(PID_FILE)
"
]
;
then
\
PID
=
$$
(
cat
$(PID_FILE)
)
;
\
if
ps
-p
$$
PID
>
/dev/null 2>&1
;
then
\
echo
"✅ 服务器正在运行,PID:
$$
PID"
;
\
echo
"端口:
$(APP_PORT)
"
;
\
echo
"日志:
$(LOG_FILE)
"
;
\
else
\
echo
"❌ 服务器未运行(PID文件存在但进程不存在)"
;
\
rm
-f
$(PID_FILE)
;
\
fi
;
\
else
\
echo
"❌ 服务器未运行"
;
\
fi
# 开发模式运行
.PHONY
:
dev
dev
:
@
echo
"开发模式运行C++程序..."
@
APP_PORT_1
=
$(APP_PORT)
$(BINARY_FILE)
# 调试模式编译
.PHONY
:
debug
debug
:
@
echo
"调试模式编译C++程序..."
@
mkdir
-p
$(BUILD_DIR)
@
$(CXX)
$(CXXFLAGS)
-g
-DDEBUG
-o
$(BINARY_FILE)
hello_world.cpp
$(LDFLAGS)
@
echo
"✅ 调试版本编译完成"
# 清理编译文件
.PHONY
:
clean
clean
:
@
echo
"清理编译文件..."
rm
-rf
$(BUILD_DIR)
@
echo
"清理完成!"
# 显示帮助信息
.PHONY
:
help
help
:
@
echo
"C++ 12.2.0 HTTP 服务器项目"
@
echo
""
@
echo
"可用命令:"
@
echo
" make install - 安装依赖并编译项目"
@
echo
" make run - 启动HTTP服务器(后台运行)"
@
echo
" make stop - 停止HTTP服务器(优雅停止)"
@
echo
" make kill - 强制杀死所有相关C++进程"
@
echo
" make restart - 重启HTTP服务器"
@
echo
" make status - 查看服务器状态"
@
echo
" make dev - 开发模式运行"
@
echo
" make debug - 调试模式编译"
@
echo
" make clean - 清理编译文件"
@
echo
" make help - 显示此帮助信息"
@
echo
""
@
echo
"示例:"
@
echo
" make run # 启动服务器"
@
echo
" make status # 查看状态"
@
echo
" make stop # 优雅停止服务器"
@
echo
" make kill # 强制停止所有相关进程"
@
echo
" make restart # 重启服务器"
@
echo
" make dev # 开发模式运行"
@
echo
" make debug # 编译调试版本"
@
echo
""
@
echo
"环境变量:"
@
echo
" APP_PORT_1 - 服务器端口(默认: 8000)"
README.md
View file @
35714658
...
@@ -52,26 +52,8 @@ make install
...
@@ -52,26 +52,8 @@ make install
# 启动服务器(后台运行)
# 启动服务器(后台运行)
make run
make run
# 开发模式运行
make dev
# 调试模式编译
make debug
# 查看服务器状态
make status
# 停止服务器
# 停止服务器
make stop
make stop
# 重启服务器
make restart
# 清理编译文件
make clean
# 查看帮助
make
help
```
```
### 3. 直接使用 GCC 命令
### 3. 直接使用 GCC 命令
...
@@ -168,11 +150,8 @@ if (env_port != nullptr) {
...
@@ -168,11 +150,8 @@ if (env_port != nullptr) {
### 查看日志
### 查看日志
```
bash
```
bash
#
使用 Makefile
查看日志
# 查看日志
tail
-f
.logs/app.log
tail
-f
.logs/app.log
# 查看服务器状态
make status
```
```
### 健康检查
### 健康检查
...
@@ -220,8 +199,8 @@ make stop
...
@@ -220,8 +199,8 @@ make stop
2.
**编译错误**
2.
**编译错误**
```
bash
```
bash
#
清理并
重新编译
# 重新编译
make clean
rm
-rf
build
make
install
make
install
```
```
...
@@ -235,13 +214,10 @@ docker build --no-cache -t test .
...
@@ -235,13 +214,10 @@ docker build --no-cache -t test .
```
bash
```
bash
# 调试模式编译
# 调试模式编译
make debug
g++
-Wall
-Wextra
-std
=
c++17
-g
-DDEBUG
-o
build/hello_world hello_world.cpp
-pthread
# 开发模式运行(显示详细日志)
make dev
# 直接运行 C++ 程序
# 直接运行 C++ 程序
./hello_world
./
build/
hello_world
```
```
## 📝 API 文档
## 📝 API 文档
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment