diff --git a/config/alpha.conf b/config/alpha.conf new file mode 100644 index 000000000..0ac769953 --- /dev/null +++ b/config/alpha.conf @@ -0,0 +1,34 @@ +# MEMGRAPH DEFAULT TESTING CONFIG + +# NOTE: all paths are relative to the run folder +# (where the executable is runned) + +# path to the codes which will be compiled +--compile_path="./compiled/" + +# path to the template (cpp) for codes generation +--template_cpp_path="./template/plan_template_cpp" + +# path to the folder with snapshots +--snapshots_path="snapshots" + +# cleaning cycle interval +# if set to -1 the GC will not run +--cleaning_cycle_sec=30 + +# snapshot cycle interval +# if set to -1 the snapshooter will not run +--snapshot_cycle_sec=300 + +# create snapshot disabled on db destruction +--snapshot_db_destruction=true + +# max number of snapshots which will be kept on the disk at some point +# if set to -1 the max number of snapshots is unlimited +--max_retained_snapshots=3 + +# by default query engine runs in interpret mode +--interpret=true + +# database recovering is disabled by default +--recovery=true diff --git a/config/testing b/config/testing.conf similarity index 100% rename from config/testing rename to config/testing.conf diff --git a/release/alpha.dockerfile b/release/alpha.dockerfile new file mode 100644 index 000000000..c3ebbeb3d --- /dev/null +++ b/release/alpha.dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:16.04 +# FROM ubuntu 16.04 # 130MB +# FROM phusion/baseimage # 220MB +# FROM debian:jessie-slim # doesn't work because CXXABI_1.3.9 & GLIBCXX_3.4.21 not found +# FROM debian:jessie # doesn't work because CXXABI_1.3.9 & GLIBCXX_3.4.21 not found + +ENV MEMGRAPH_CONFIG /memgraph/config/memgraph + +ARG build_name + +COPY ${build_name} /memgraph + +WORKDIR /memgraph + +ENTRYPOINT ["./memgraph"] +CMD [""] diff --git a/release/alpha_compiler.dockerfile b/release/alpha_compiler.dockerfile deleted file mode 100644 index da50b48f4..000000000 --- a/release/alpha_compiler.dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM ubuntu:16.04 - -RUN apt-get update \ - && apt-get install -y clang uuid-dev \ - && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -ENV BINARY_NAME memgraph_552_545344b_mg_release_debug -ENV MEMGRAPH_CONFIG /memgraph/config/memgraph.yaml - -COPY $BINARY_NAME /memgraph - -WORKDIR /memgraph - -CMD ./memgraph diff --git a/release/alpha_interpreter.dockerfile b/release/alpha_interpreter.dockerfile deleted file mode 100644 index 27d85fc74..000000000 --- a/release/alpha_interpreter.dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM ubuntu:16.04 - -RUN apt-get update \ - && apt-get install -y clang uuid-dev \ - && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -ENV MEMGRAPH_CONFIG /memgraph/config/interpreter.yaml -ARG build_name -COPY ${build_name} /memgraph - -WORKDIR /memgraph -CMD ./memgraph diff --git a/release/build_interpreter b/release/build_interpreter index 1c07d7031..b0f012800 100755 --- a/release/build_interpreter +++ b/release/build_interpreter @@ -4,11 +4,14 @@ # Build & package (collect all required files in a folder). function print_help () { - echo "Usage: $0 [--skip-compile]" + echo "Usage: $0 [OPTION] --version MAJOR.MINOR.PATCH" + echo "Optional arguments:" + echo -e " --h|--help Print help." + echo -e " --skip-compile Skip compilation process." + echo -e " --build-type CMAKE_BUILD_TYPE options are: Debug|Release|RelWithDebInfo|MinSizeRel|Coverage|None (default is Debug)." + echo -e " --config-file Memgraph config file name (default is testing.conf)" } -echo "Memgraph Release Building..." - if [[ $EUID -eq 0 ]]; then echo "This script must NOT be run as root!" 1>&2 exit 1 @@ -18,16 +21,31 @@ release_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" project_dir="${release_dir}/.." skip_compile=false +build_type="Debug" +config_file="testing.conf" +version="" while [[ $# -gt 0 ]] do case $1 in -h|--help) print_help - exit -1 + exit 1 ;; --skip-compile) skip_compile=true ;; + --build-type) + build_type=$2 + shift + ;; + --config-file) + config_file=$2 + shift + ;; + --version) + version=$2 + shift + ;; *) # unknown option ;; @@ -35,6 +53,17 @@ do shift # past argument or value done +if [[ ! ${version} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo -e "Something is wrong with your version number. Semantic version number is required (MAJOR.MINOR.PATCH).\n" + print_help + exit 1 +fi + +# TODO: Somehow check the correct value. One solution would be to create +# a file with the current version number value. It's not required for now. + +echo "Memgraph Release Building (${version})" + echo "Skip compile: ${skip_compile}" if [[ "${skip_compile}" == false ]]; then @@ -45,7 +74,7 @@ if [[ "${skip_compile}" == false ]]; then # compile memgraph cd ${project_dir}/build rm -rf ./* - cmake -DCMAKE_BUILD_TYPE:String=debug .. + cmake -DCMAKE_BUILD_TYPE:String=${build_type} .. make -j8 fi @@ -57,10 +86,11 @@ release_folder=${release_dir}/${exe_name} # extract only required files # create dst directory cd ${release_dir} -mkdir -p ${release_folder} +mkdir -p ${release_folder}/config echo "Full build name: ${exe_name}" > ${release_folder}/build.info +echo "${version}" > ${release_folder}/VERSION # copy binary & config cp ${project_dir}/build/${exe_name} ${release_folder}/memgraph -cp -r ${project_dir}/config ${release_folder}/config +cp ${project_dir}/config/${config_file} ${release_folder}/config/memgraph echo "Memgraph Build ${exe_name} DONE" diff --git a/release/package_deploy b/release/package_deploy index 5d91803a9..d4dccc81f 100755 --- a/release/package_deploy +++ b/release/package_deploy @@ -3,7 +3,7 @@ # Build, Package (docker image) & Deploy Memgraph function print_help () { - echo "Usage: $0 [-h|--help] -s|--server deploy_server_domain -u|--user username -k|--key private_user_key [--skip-compile]" + echo "Usage: $0 [-h|--help] -s|--server deploy_server_domain -u|--user username -k|--key private_user_key --version X.Y.Z [--skip-compile]" } working_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -12,6 +12,7 @@ project_dir="${working_dir}/.." # argument parsing required_args_no=0 skip_compile=false +version=0 while [[ $# -gt 0 ]] do case $1 in @@ -37,15 +38,20 @@ do --skip-compile) skip_compile=true ;; + --version) + version=$2 + required_args_no=$((required_args_no+1)) + shift + ;; *) # unknown option ;; esac shift # past argument or value done -if [[ ${required_args_no} -ne 3 ]]; then +if [[ ${required_args_no} -ne 4 ]]; then print_help - exit 1 + exit -1 fi echo "Deploy server: ${deploy_server}" @@ -55,22 +61,26 @@ echo "Skip compile: ${skip_compile}" ## build binary if [[ "${skip_compile}" == true ]]; then - ${working_dir}/build_interpreter --skip-compile + ${working_dir}/build_interpreter --skip-compile --version ${version} else - ${working_dir}/build_interpreter + ${working_dir}/build_interpreter --version ${version} fi ## build package (docker image) cd ${working_dir} package_name=`ls -t -d memgraph_*/ | head -1 | sed 's/.$//'` -docker build -t ${package_name} -f ${working_dir}/alpha_interpreter.dockerfile --build-arg build_name=${package_name} . -docker save ${package_name} > ${package_name}.tar.gz +# for some reason docker image has to be lowercase string +# and because our package name is based on the cmake build type +# string (which can be camel case) the package name has to be transformed +docker_image_name=$(echo "${package_name}"| tr '[:upper:]' '[:lower:]') +docker build -t ${docker_image_name} -f ${working_dir}/alpha.dockerfile --build-arg build_name=${package_name} . +docker save ${docker_image_name} > ${docker_image_name}.tar.gz ## deploy # copy package -scp -i ${deploy_key} ${package_name}.tar.gz ${deploy_user}@${deploy_server}:/home/${deploy_user} +scp -i ${deploy_key} ${docker_image_name}.tar.gz ${deploy_user}@${deploy_server}:/home/${deploy_user} # load package -ssh -i ${deploy_key} ${deploy_user}@${deploy_server} docker load -i /home/${deploy_user}/${package_name}.tar.gz +ssh -i ${deploy_key} ${deploy_user}@${deploy_server} docker load -i /home/${deploy_user}/${docker_image_name}.tar.gz # spin up the instance public_port=$(echo ${package_name} | grep -o "memgraph_[0-9]*_" | sed 's/[^0-9]*//g') -ssh -i ${deploy_key} ${deploy_user}@${deploy_server} docker run -d --name ${package_name} -p ${public_port}:7687 ${package_name} +ssh -i ${deploy_key} ${deploy_user}@${deploy_server} docker run -d --name ${docker_image_name} -p ${public_port}:7687 ${docker_image_name} diff --git a/src/memgraph_bolt.cpp b/src/memgraph_bolt.cpp index ee1a8a3ad..efc1839f8 100644 --- a/src/memgraph_bolt.cpp +++ b/src/memgraph_bolt.cpp @@ -86,7 +86,8 @@ void load_config(int &argc, char **&argv) { int main(int argc, char **argv) { fs::current_path(fs::path(argv[0]).parent_path()); load_config(argc, argv); -// Logging init. + + // Logging init. #ifdef SYNC_LOGGER logging::init_sync(); #else @@ -150,6 +151,12 @@ int main(int argc, char **argv) { std::exit(EXIT_SUCCESS); }); + // register SIGINT handler + SignalHandler::register_handler(Signal::Interupt, [&server]() { + server.Shutdown(); + std::exit(EXIT_FAILURE); + }); + // Start worker threads. logger.info("Starting {} workers", FLAGS_num_workers); server.Start(FLAGS_num_workers);