From 4e1bbfa93cd0fdaf4dfa0a341b001a27116b26fc Mon Sep 17 00:00:00 2001 From: frank <625727796@qq.com> Date: Fri, 4 May 2018 17:12:48 +0800 Subject: [PATCH] build & install --- .gitignore | 4 +++- CMakeLists.txt | 6 ++++-- README.md | 7 +++++-- base/palloc.c | 2 +- build.sh | 14 ++++++++++++++ config.h | 2 +- fancy.c | 2 +- fancy.conf | 8 ++++---- 8 files changed, 33 insertions(+), 12 deletions(-) create mode 100755 build.sh diff --git a/.gitignore b/.gitignore index 1719b14..e53f613 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ /profile data.pdf fancy.pid -fancy.log \ No newline at end of file +fancy.log +/install/ +/build/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7147c5b..2f03f16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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") \ No newline at end of file +install(TARGETS fancy DESTINATION ./) +install(FILES fancy.conf DESTINATION ./) +install(DIRECTORY html DESTINATION ./) \ No newline at end of file diff --git a/README.md b/README.md index efad4fe..dc39b5e 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/base/palloc.c b/base/palloc.c index 3478747..e4707d6 100644 --- a/base/palloc.c +++ b/base/palloc.c @@ -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; } diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..96f8b7e --- /dev/null +++ b/build.sh @@ -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 $* \ No newline at end of file diff --git a/config.h b/config.h index ce882c3..90631f8 100644 --- a/config.h +++ b/config.h @@ -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" diff --git a/fancy.c b/fancy.c index 9392bd8..c63a638 100644 --- a/fancy.c +++ b/fancy.c @@ -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"); diff --git a/fancy.conf b/fancy.conf index 5fc9e7e..8bf9319 100644 --- a/fancy.conf +++ b/fancy.conf @@ -1,9 +1,9 @@ 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; @@ -11,7 +11,7 @@ events { } server { - listen_on 9878; + listen_on 8080; request_timeout 30000; upstream_timeout 50000; @@ -21,7 +21,7 @@ server { accept_defer 5; location / { - root /home/frank/nodejs/blog/public; + root ./html; index index.html index.htm ; } location / {