Alpha package scripts.
Summary: Alpha package scripts. Alpha version is going to be shipped within docker. Reviewers: teon.banek, mferencevic Reviewed By: teon.banek Subscribers: pullbot, buda Differential Revision: https://phabricator.memgraph.io/D436
This commit is contained in:
parent
7091be1891
commit
f84f9af244
34
config/alpha.conf
Normal file
34
config/alpha.conf
Normal file
@ -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
|
16
release/alpha.dockerfile
Normal file
16
release/alpha.dockerfile
Normal file
@ -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 [""]
|
@ -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
|
@ -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
|
@ -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"
|
||||
|
@ -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}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user