Skip to content

Commit 4e1bbfa

Browse files
committed
build & install
1 parent 0182127 commit 4e1bbfa

File tree

8 files changed

+33
-12
lines changed

8 files changed

+33
-12
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
/profile
77
data.pdf
88
fancy.pid
9-
fancy.log
9+
fancy.log
10+
/install/
11+
/build/

CMakeLists.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ set(C_FLAGS
1717
)
1818
string(REPLACE ";" " " CMAKE_C_FLAGS "${C_FLAGS}")
1919

20-
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
20+
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
2121
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
2222

2323
include_directories(./base ./event ./http)
@@ -35,4 +35,6 @@ aux_source_directory(. SRC)
3535
add_executable(fancy ${SRC})
3636
target_link_libraries(fancy base event http)
3737

38-
install(TARGETS fancy DESTINATION "/usr/bin")
38+
install(TARGETS fancy DESTINATION ./)
39+
install(FILES fancy.conf DESTINATION ./)
40+
install(DIRECTORY html DESTINATION ./)

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ fancy是一个基于事件驱动(epoll)的多进程web服务器. 其原理与Ngi
2323
## 使用
2424

2525
```
26-
cmake .
27-
make
26+
git clone https://github.com/guangqianpeng/fancy.git
27+
cd fancy
28+
./build && ./build install
29+
cd install
30+
./fancy
2831
```

base/palloc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void *palloc(mem_pool *pool, size_t size)
4949

5050
last = align_ptr(p->last, MEM_POOL_ALIGNMENT);
5151

52-
if (p->end - last >= size) {
52+
if (p->end - last >= (long) size) {
5353
p->last = last + size;
5454
return last;
5555
}

build.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
set -x
4+
5+
SOURCE_DIR=`pwd`
6+
BUILD_DIR=${BUILD_DIR:-./build}
7+
INSTALL_DIR=${INSTALL_DIR:-../install}
8+
9+
mkdir -p $BUILD_DIR \
10+
&& cd $BUILD_DIR \
11+
&& cmake \
12+
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
13+
$SOURCE_DIR \
14+
&& make $*

config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "palloc.h"
1010

11-
#define FANCY_PREFIX "/home/frank/ClionProjects/fancy/"
11+
#define FANCY_PREFIX "./"
1212
#define FANCY_PID_FILE FANCY_PREFIX"fancy.pid"
1313
#define FANCY_CONFIG_FILE FANCY_PREFIX"fancy.conf"
1414

fancy.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ int main(int argc, char **argv)
7777
exit(EXIT_FAILURE);
7878
}
7979

80-
/* 单进程模式 */
80+
/* single process mode */
8181
if (!master_process) {
8282
run_single_process();
8383
LOG_INFO("quit");

fancy.conf

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
daemonize off;
22
master_process off;
3-
worker_processes 3;
3+
worker_processes 1;
44

55
log_level debug;
6-
log_path stdout;#/home/frank/ClionProjects/fancy/html/fancy.log;
6+
log_path ./fancy.log;
77

88
events {
99
worker_connections 10240;
1010
epoll_events 1024;
1111
}
1212

1313
server {
14-
listen_on 9878;
14+
listen_on 8080;
1515

1616
request_timeout 30000;
1717
upstream_timeout 50000;
@@ -21,7 +21,7 @@ server {
2121
accept_defer 5;
2222

2323
location / {
24-
root /home/frank/nodejs/blog/public;
24+
root ./html;
2525
index index.html index.htm ;
2626
}
2727
location / {

0 commit comments

Comments
 (0)