diff --git a/build.sh b/build.sh deleted file mode 100755 index 644a5df64..000000000 --- a/build.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash - -#color code -C_RED="\033[31m" -C_GREEN="\033[32m" - -C_END="\033[0m" - -BUILD_TIME=$(git log -1 --format=%ai) -BUILD_TIME=${BUILD_TIME: 0: 10} - -COMMIT_ID=$(git rev-parse HEAD) -SHORT_COMMIT_ID=${COMMIT_ID: 0: 8} - -BUILD_TYPE=Release -VERBOSE=0 -CMAKE_FLAGS="" -MAKE_FLAGS="" -PREFIX="cmake-build" - -ARGS=`getopt -a -o h -l help,debug,verbose,prefix: -- "$@"` -function show_help() { - echo " - -h --help show help - --debug compile with debug - --verbose compile with verbose - --prefix compile output path - " - exit 0 -} - -eval set -- "${ARGS}" -while true -do - case "$1" in - -h|--help) - show_help - ;; - --debug) - BUILD_TYPE=debug - ;; - --verbose) - CMAKE_FLAGS="${CMAKE_FLAGS} -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON" - MAKE_FLAGS="${MAKE_FLAGS} VERBOSE=1" - ;; - --prefix) - PREFIX=$2 - shift - ;; - --) - shift - break - ;; - esac -shift -done - -if [ ! -f "/proc/cpuinfo" ];then - CPU_CORE=$(sysctl -n hw.ncpu) -else - CPU_CORE=$(cat /proc/cpuinfo| grep "processor"| wc -l) -fi -if [ ${CPU_CORE} -eq 0 ]; then - CPU_CORE=1 -fi - -echo "cpu core ${CPU_CORE}" - -echo "BUILD_TYPE:" $BUILD_TYPE -echo "CMAKE_FLAGS:" $CMAKE_FLAGS -echo "MAKE_FLAGS:" $MAKE_FLAGS - -if [ "${BUILD_TYPE}" == "Release" ]; then - PREFIX="${PREFIX}-release" -else - PREFIX="${PREFIX}-debug" -fi - -cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${CMAKE_FLAGS} -S . -B ${PREFIX} -cmake --build ${PREFIX} -- ${MAKE_FLAGS} -j ${CPU_CORE} - -if [ $? -eq 0 ]; then - echo -e "pikiwidb compile complete, output file ${C_GREEN} ${BUILD_DIR}/pikiwidb ${C_END}" -else - echo -e "${C_RED} pikiwidb compile fail ${C_END}" - exit 1 -fi diff --git a/clear.sh b/clear.sh deleted file mode 100755 index c936f446e..000000000 --- a/clear.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -# ****************************************************** -# DESC : -# AUTHOR : Alex Stocks -# VERSION : 1.0 -# LICENCE : Apache License 2.0 -# EMAIL : alexstocks@foxmail.com -# MOD : 2023-07-31 17:03 -# FILE : clear.sh -# ****************************************************** - -rm -rf ./build-release -rm -rf ./build-debug -rm -rf ./bin diff --git a/pikiwidb.conf b/etc/conf/pikiwidb.conf similarity index 100% rename from pikiwidb.conf rename to etc/conf/pikiwidb.conf diff --git a/etc/script/load.sh b/etc/script/load.sh new file mode 100755 index 000000000..0fa9d101e --- /dev/null +++ b/etc/script/load.sh @@ -0,0 +1,117 @@ +#!/bin/bash + +#color code +C_RED="\033[31m" +C_GREEN="\033[32m" + +C_END="\033[0m" + +BUILD_TIME=$(git log -1 --format=%ai) +BUILD_TIME=${BUILD_TIME: 0: 10} + +COMMIT_ID=$(git rev-parse HEAD) +SHORT_COMMIT_ID=${COMMIT_ID: 0: 8} + +BUILD_TYPE=Release +VERBOSE=0 +CMAKE_FLAGS="" +MAKE_FLAGS="" +PREFIX="cmake-build" + +PWD=`pwd` +PROJECT_HOME="${PWD}/../" +CONF_FILE="${PROJECT_HOME}/etc/conf/pikiwidb.conf" +ARGS=`getopt -a -o h -l help,debug,verbose,prefix: -- "$@"` + +function build() { + if [ ! -f "/proc/cpuinfo" ];then + CPU_CORE=$(sysctl -n hw.ncpu) + else + CPU_CORE=$(cat /proc/cpuinfo| grep "processor"| wc -l) + fi + if [ ${CPU_CORE} -eq 0 ]; then + CPU_CORE=1 + fi + + echo "cpu core ${CPU_CORE}" + + echo "BUILD_TYPE:" $BUILD_TYPE + echo "CMAKE_FLAGS:" $CMAKE_FLAGS + echo "MAKE_FLAGS:" $MAKE_FLAGS + + if [ "${BUILD_TYPE}" == "Release" ]; then + PREFIX="${PREFIX}-release" + else + PREFIX="${PREFIX}-debug" + fi + + cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${CMAKE_FLAGS} -S . -B ${PREFIX} + cmake --build ${PREFIX} -- ${MAKE_FLAGS} -j ${CPU_CORE} + + if [ $? -eq 0 ]; then + echo -e "pikiwidb compile complete, output file ${C_GREEN} ${BUILD_DIR}/pikiwidb ${C_END}" + else + echo -e "${C_RED} pikiwidb compile fail ${C_END}" + exit 1 + fi +} + +function clear() { + rm -rf ${PROJECT_HOME}/deps-debug + rm -rf ${PROJECT_HOME}/deps-release + rm -rf ${PROJECT_HOME}/cmake-build-debug + rm -rf ${PROJECT_HOME}/cmake-build-release + rm -rf ${PROJECT_HOME}/build + rm -rf ${PROJECT_HOME}/build-release + rm -rf ${PROJECT_HOME}/build-debug + rm -rf ${PROJECT_HOME}/bin +} + +function show_help() { + echo " + $0 --debug compile with debug + $0 --clear clear useless directory + $0 -h|--help show help + $0 --prefix compile output path + $0 --verbose compile with verbose + " + exit 0 +} + +eval set -- "${ARGS}" +while true +do + case "$1" in + -c|--clear) + clear + exit 0 + ;; + + --debug) + BUILD_TYPE=debug + build + ;; + + -h|--help) + show_help + ;; + + --prefix) + PREFIX=$2 + shift + build + ;; + + --verbose) + CMAKE_FLAGS="${CMAKE_FLAGS} -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON" + MAKE_FLAGS="${MAKE_FLAGS} VERBOSE=1" + build + ;; + + --) + shift + break + ;; + esac +shift +done diff --git a/pikiwidbtests.sh b/etc/script/pikiwidbtests.sh similarity index 100% rename from pikiwidbtests.sh rename to etc/script/pikiwidbtests.sh diff --git a/save_load.sh b/etc/script/save_load.sh similarity index 60% rename from save_load.sh rename to etc/script/save_load.sh index 09f36c260..a45170dc9 100755 --- a/save_load.sh +++ b/etc/script/save_load.sh @@ -3,8 +3,13 @@ killall -9 pikiwidb mkdir leader follower1 -cd leader && ulimit -n 99999 && rm -fr * && ../bin/pikiwidb ../pikiwidb.conf --port 7777 & -cd follower1 && ulimit -n 99999 && rm -fr * && ../bin/pikiwidb ../pikiwidb.conf --port 8888 & + +PWD=`pwd` +PROJECT_HOME="${PWD}/../" +BIN="${PROJECT_HOME}/bin/pikiwidb" +CONF="${PROJECT_HOME}/etc/conf/pikiwidb.conf" +cd leader && ulimit -n 99999 && rm -fr * && ${BIN} ${CONF} --port 7777 & +cd follower1 && ulimit -n 99999 && rm -fr * && ${BIN} ${CONF} --port 8888 & sleep 5 redis-cli -p 7777 raft.cluster init