Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
c12.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
c12.2.0-template
Commits
64268e11
Commit
64268e11
authored
Sep 17, 2025
by
xiezhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix makefile
parent
e5bd1ad2
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 @
64268e11
...
...
@@ -49,11 +49,7 @@ run: install
# 停止命令
.PHONY
:
stop
stop
:
kill
# 强制杀死所有相关C进程
.PHONY
:
kill
kill
:
stop
:
@
echo
"正在查找并杀死所有相关的C进程..."
@
PIDS
=
$$
(
ps aux |
grep
-E
"hello_world|
$(APP_NAME)
"
|
grep
-v
grep
|
awk
'{print $$2}'
)
;
\
if
[
-n
"
$$
PIDS"
]
;
then
\
...
...
@@ -68,75 +64,4 @@ kill:
echo
"未找到相关的C进程"
;
\
fi
@
rm
-f
$(PID_FILE)
@
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)
@
$(CC)
$(CFLAGS)
-g
-DDEBUG
-o
$(BINARY_FILE)
hello_world.c
$(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)"
@
echo
"✅ 停止操作完成"
README.md
View file @
64268e11
...
...
@@ -52,26 +52,8 @@ make install
# 启动服务器(后台运行)
make run
# 开发模式运行
make dev
# 调试模式编译
make debug
# 查看服务器状态
make status
# 停止服务器
make stop
# 重启服务器
make restart
# 清理编译文件
make clean
# 查看帮助
make
help
```
### 3. 直接使用 GCC 命令
...
...
@@ -167,11 +149,8 @@ if (env_port != NULL) {
### 查看日志
```
bash
#
使用 Makefile
查看日志
# 查看日志
tail
-f
.logs/app.log
# 查看服务器状态
make status
```
### 健康检查
...
...
@@ -219,8 +198,8 @@ make stop
2.
**编译错误**
```
bash
#
清理并
重新编译
make clean
# 重新编译
rm
-rf
build
make
install
```
...
...
@@ -234,13 +213,10 @@ docker build --no-cache -t test .
```
bash
# 调试模式编译
make debug
# 开发模式运行(显示详细日志)
make dev
gcc
-Wall
-Wextra
-std
=
c11
-g
-DDEBUG
-o
build/hello_world hello_world.c
-pthread
# 直接运行 C 程序
./hello_world
./
build/
hello_world
```
## 📝 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