Skip to content

Commit

Permalink
build & install
Browse files Browse the repository at this point in the history
  • Loading branch information
guangqianpeng committed May 4, 2018
1 parent 0182127 commit 4e1bbfa
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
/profile
data.pdf
fancy.pid
fancy.log
fancy.log
/install/
/build/
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set(C_FLAGS
)
string(REPLACE ";" " " CMAKE_C_FLAGS "${C_FLAGS}")

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

include_directories(./base ./event ./http)
Expand All @@ -35,4 +35,6 @@ aux_source_directory(. SRC)
add_executable(fancy ${SRC})
target_link_libraries(fancy base event http)

install(TARGETS fancy DESTINATION "/usr/bin")
install(TARGETS fancy DESTINATION ./)
install(FILES fancy.conf DESTINATION ./)
install(DIRECTORY html DESTINATION ./)
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ fancy是一个基于事件驱动(epoll)的多进程web服务器. 其原理与Ngi
## 使用

```
cmake .
make
git clone https://github.com/guangqianpeng/fancy.git
cd fancy
./build && ./build install
cd install
./fancy
```
2 changes: 1 addition & 1 deletion base/palloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void *palloc(mem_pool *pool, size_t size)

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

if (p->end - last >= size) {
if (p->end - last >= (long) size) {
p->last = last + size;
return last;
}
Expand Down
14 changes: 14 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

set -x

SOURCE_DIR=`pwd`
BUILD_DIR=${BUILD_DIR:-./build}
INSTALL_DIR=${INSTALL_DIR:-../install}

mkdir -p $BUILD_DIR \
&& cd $BUILD_DIR \
&& cmake \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
$SOURCE_DIR \
&& make $*
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "palloc.h"

#define FANCY_PREFIX "/home/frank/ClionProjects/fancy/"
#define FANCY_PREFIX "./"
#define FANCY_PID_FILE FANCY_PREFIX"fancy.pid"
#define FANCY_CONFIG_FILE FANCY_PREFIX"fancy.conf"

Expand Down
2 changes: 1 addition & 1 deletion fancy.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}

/* 单进程模式 */
/* single process mode */
if (!master_process) {
run_single_process();
LOG_INFO("quit");
Expand Down
8 changes: 4 additions & 4 deletions fancy.conf
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
daemonize off;
master_process off;
worker_processes 3;
worker_processes 1;

log_level debug;
log_path stdout;#/home/frank/ClionProjects/fancy/html/fancy.log;
log_path ./fancy.log;

events {
worker_connections 10240;
epoll_events 1024;
}

server {
listen_on 9878;
listen_on 8080;

request_timeout 30000;
upstream_timeout 50000;
Expand All @@ -21,7 +21,7 @@ server {
accept_defer 5;

location / {
root /home/frank/nodejs/blog/public;
root ./html;
index index.html index.htm ;
}
location / {
Expand Down

0 comments on commit 4e1bbfa

Please sign in to comment.