diff --git a/.gitignore b/.gitignore index ac3fbeeaf..1c78f2aad 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ CMakeLists.txt # Packages *.tar.gz *.tar.bz2 +*.pc # Logs *.log diff --git a/configure.ac b/configure.ac index 067600550..799f7dc0d 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ AC_CONFIG_HEADERS([config.h:config.h.in]) AC_CONFIG_MACRO_DIR([m4]) # Initialize automake -AM_INIT_AUTOMAKE([1.11 foreign]) +AM_INIT_AUTOMAKE([1.11 foreign subdir-objects]) # Checks for language AC_LANG([C]) diff --git a/debian/Dockerfile b/debian/Dockerfile new file mode 100644 index 000000000..0a57db03f --- /dev/null +++ b/debian/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:14.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y \ + build-essential \ + bzr-builddeb \ + bzr-git \ + dh-autoreconf \ + dh-exec \ + dh-make \ + git \ + libssl-dev \ + && rm -rf /var/lib/apt/lists/* + +CMD /bin/bash diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 000000000..7c81943dc --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,4 @@ +dynomite for Debian +------------------- + + -- Estelle Poulin Tue, 09 Apr 2019 03:38:44 +0000 diff --git a/debian/README.source b/debian/README.source new file mode 100644 index 000000000..262cbe09c --- /dev/null +++ b/debian/README.source @@ -0,0 +1,5 @@ +dynomite for Debian +------------------- + + -- Estelle Poulin Tue, 09 Apr 2019 03:38:44 +0000 + diff --git a/debian/build-enter.sh b/debian/build-enter.sh new file mode 100755 index 000000000..d0f4565d7 --- /dev/null +++ b/debian/build-enter.sh @@ -0,0 +1,12 @@ +#! /usr/bin/env bash + +docker run -it \ + --rm \ + -u $(id -u):$(id -g) \ + -e HOME="$HOME" \ + -e USER="$USER" \ + -v "$HOME":"$HOME" \ + -v /etc/passwd:/etc/passwd \ + -v /etc/group:/etc/group \ + -w "$HOME" \ + local/debbuild diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 000000000..a42aa72d5 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +dynomite (0.7.0-1) trusty; urgency=low + + * Initial release. + + -- Estelle Poulin Tue, 09 Apr 2019 03:38:44 +0000 diff --git a/debian/compat b/debian/compat new file mode 100644 index 000000000..ec635144f --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 000000000..b0bf30f45 --- /dev/null +++ b/debian/control @@ -0,0 +1,15 @@ +Source: dynomite +Section: database +Priority: optional +Maintainer: Estelle Poulin +Build-Depends: debhelper (>= 9.0.0), dh-autoreconf (>= 9), dh-exec (>= 0.12) +Standards-Version: 3.9.5 +Homepage: https://github.com/netflix/dynomite +Vcs-Git: git://github.com:netflix/dynomite.git +Vcs-Browser: https://github.com/netflix/dynomite.git + +Package: dynomite +Architecture: amd64 +Depends: ${shlibs:Depends}, ${misc:Depends} +Description:Generic dynamo implementation for different + k-v storage engines. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 000000000..e346e9977 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,46 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: dynomite +Source: https://github.com/Netflix/dynomite + +Files: * +Copyright: 2018-2019 Netflix +License: Apache-2.0 + +Files: debian/init debian/service +Copyright: 2018-2019 Netflix +License: Apache-2.0 + +License: Apache-2.0 + On Debian systems, the full text of the Apache License version 2 + can be found in the file /usr/share/common-licenses/Apache-2.0. + +Files: debian/* +Copyright: © 2019 Estelle Poulin +License: BSD + Copyright (c) The Regents of the University of California. + All rights reserved. + . + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + diff --git a/debian/default b/debian/default new file mode 100644 index 000000000..5292be0f2 --- /dev/null +++ b/debian/default @@ -0,0 +1,2 @@ +# Run /usr/sbin/dynomite --help for options. +# DAEMON_OPTS="$DAEMON_OPTS -v 5" diff --git a/debian/docs b/debian/docs new file mode 100644 index 000000000..2e5ec3f47 --- /dev/null +++ b/debian/docs @@ -0,0 +1,6 @@ +CONTRIBUTING.md +NOTICE +OSSMETADATA +README.md +docs +notes diff --git a/debian/examples b/debian/examples new file mode 100644 index 000000000..5b597a1ed --- /dev/null +++ b/debian/examples @@ -0,0 +1,3 @@ +conf +docker +init diff --git a/debian/init b/debian/init new file mode 100755 index 000000000..82c0bfbf1 --- /dev/null +++ b/debian/init @@ -0,0 +1,190 @@ +#! /bin/sh + +### BEGIN INIT INFO +# Provides: dynomite +# Required-Start: $remote_fs $syslog $network $time +# Required-Stop: $remote_fs $syslog $network $time +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: dynamo layer for different k-v storage engines +# Description: dynomite is a thin dynamo proxy layer that provides +# high availability (HA) and multi-datacenter replication +# for Redis and MemCached. +### END INIT INFO + +NAME=dynomite +DESC="distributed dynamo layer" +PATH=/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin +PIDFILE=/var/run/${NAME}.pid +CONFIG=/etc/dynomite/${NAME}.yml +LOG=/var/log/dynomite.log +INIT_OPTIONS=/etc/default/${NAME} +# RHEL specific file +#SYSTEM_CONFIG=/etc/sysconfig/${NAME} +DAEMON=/usr/sbin/${NAME} +DAEMON_OPTS="-d -c ${CONFIG} -p ${PIDFILE} -o ${LOG}" +# TODO: Runas USER +#USER="dynomite" +#GROUP="dynomite" +RETVAL=0 + +if [ ! -x $DAEMON ] ; then + echo "Executable '${DAEMON}' was not found." + exit 0 +fi + +if [ ! -f "$CONFIG" ] ; then + echo "Configuration file '${CONFIG}' was not found." + exit 0 +fi + +if [ -r $INIT_OPTIONS ]; then + . $INIT_OPTIONS +fi + +. /lib/lsb/init-functions + +# RHEL system configuration +#if [ -r $SYSTEM_CONFIG ];then +# . $SYSTEM_CONFIG +#fi + +# +# Start dynomite +# +# Return +# 0 = daemon has been started +# 1 = daemon was already running +# 2 = daemon could not be started +# +start_dynomite () { + local IS_RUNNING=$(is_running) + + if [ $IS_RUNNING = false ] ; then + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \ + --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ + $DAEMON_OPTS 2>/dev/null \ + || return 2 + # RHEL specific init.d script: touch /var/lock/subsys/${NAME} + else + return 1 # daemon already running + fi +} + +# +# Stop dynomite +# +# Return +# 0 = daemon has been stopped +# 1 = daemon was already stopped (so don't use --oknodo) +# 2 = daemon could not be stopped +# other status code = a failure occurred +# +stop_dynomite () { + local IS_RUNNING=$(is_running) + + if [ $IS_RUNNING = true ] ; then + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \ + --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS + RETVAL="$?" + else + RETVAL=1 # deamon already stopped + fi + + sleep 1 + return "$RETVAL" +} + +# +# Test the Dynomite configuration +# +test_dynomite_config () { + $DAEMON -t $DAEMON_OPTS >/dev/null 2>&1 + RETVAL="$?" + return "$RETVAL" +} + +# +# Check if a Dynomite process exists +# +# Return via echo +# true = PIDFILE exists and process is running +# false = PIDFILE exists but process is not running +# false = PIDFILE does not exist +# +is_running () { + if [ -s $PIDFILE ] ; then + PID=`head -n 1 $PIDFILE 2>/dev/null`; + if [ ! -z "`ps --no-heading $PID`" ] ; then + echo true # PIDFILE exists, process running + else + # RHEL specific init.d script: rm -r /var/lock/subsys/${NAME} + rm -f $PIDFILE; + echo false # PIDFILE exists, process not running + fi + else + echo false # PIDFILE does not exist + fi +} + +case "$1" in + start) + log_daemon_msg "Starting ${DESC}..." "$NAME" + start_dynomite + case "$?" in + 0|1) log_end_msg 0 ;; + 2) log_end_msg 1 ;; + esac + ;; + stop) + log_daemon_msg "Stopping ${DESC}..." "$NAME" + stop_dynomite + + case "$?" in + 0|1) log_end_msg 0 ;; + 2) log_end_msg 1 ;; + esac + ;; + status) + status_of_proc -p $PIDFILE "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + restart|reload|force-reload) + log_daemon_msg "Restarting $DESC..." "$NAME" + + # Do not stop the dynomite server if there is a configuration error as + # it will not start again. Notify the user if there is a configuration + # error. + if ! test_dynomite_config; then + log_end_msg 1 # Configuration error + exit 0 + fi + + stop_dynomite + sleep 1 # Hack to prevent failure of restart when dynomite is stopped + case "$?" in + 0) + start_dynomite + case "$?" in + 0) log_end_msg 0 ;; # daemon started or already running + *) log_end_msg 1 ;; # daemon failed to start + esac + ;; + *) + # stop() failed + log_end_msg 1 + ;; + esac + ;; + configtest|testconfig|conftest|testconf) + log_daemon_msg "Testing $NAME configuration" + test_dynomite_config + log_end_msg $? + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|reload|testconf}" + exit 1 + ;; +esac +exit $RETVAL diff --git a/debian/install b/debian/install new file mode 100755 index 000000000..ca35108d1 --- /dev/null +++ b/debian/install @@ -0,0 +1,5 @@ +#! /usr/bin/dh-exec +init/systemd_environment__dynomite => etc/environment.d/dynomite.conf +dist/conf/dynomite.yml => etc/dynomite/dynomite.yml +dist/ufw/dynomite => etc/ufw/applications.d/dynomite +dist/firewalld/dynomite.xml => usr/lib/firewalld/services/dynomite.xml diff --git a/debian/patches/addDefaultConfig.diff b/debian/patches/addDefaultConfig.diff new file mode 100644 index 000000000..e8c289fff --- /dev/null +++ b/debian/patches/addDefaultConfig.diff @@ -0,0 +1,97 @@ +Adds a default configuration file basded on README.md. +--- /dev/null ++++ b/dist/conf/dynomite.yml +@@ -0,0 +1,93 @@ ++# References: ++# https://github.com/Netflix/dynomite/wiki/Architecture ++# /usr/share/docs/dynomite/notes/recommendation.md#liveness ++ ++dyn_o_mite: ++ # Specify environment of a node. Currently supports aws and network (for ++ # physical datacenter). ++ #env: ++ ++ # The name of the datacenter. Please refer to architecture document. ++ #datacenter: ++ ++ # The name of the rack. Please refer to architecture document. ++ #rack: ++ ++ # The port that dynomite nodes use to inter-communicate and gossip. ++ #dyn_listen: ++ ++ # Enable gossip instead of static tokens (default: false). Gossip is ++ # experimental. ++ #enable_gossip: false ++ ++ # The sleeping time in milliseconds at the end of a gossip round. ++ #gos_interval: ++ ++ # The token(s) owned by a node. Currently, we don't support vnode yet so this ++ # only works with one token for the time being. ++ #tokens: ++ ++ # A seed provider implementation to provide a list of seed nodes. ++ #dyn_seed_provider: ++ ++ # A list of seed nodes in the format: address:port:rack:dc:tokens (note that ++ # vnode is not supported yet). ++ #dyn_seeds: ++ # - address:port:rack:dc:tokens ++ ++ # The listening address and port (name:port or ip:port) for this server pool. ++ #listen: name/ip:port ++ ++ # The timeout value in msec that we wait for to establish a connection to the ++ # server or receive a response from a server. By default, we wait ++ # indefinitely. ++ #timeout: 0 ++ ++ # A boolean value that controls if dynomite should preconnect to all the ++ # servers in this pool on process start. Defaults to false. ++ #preconnect: false ++ ++ # An integer value that controls if a server pool speaks redis (0) or ++ # memcached (1) or other protocol. Defaults to redis (0). ++ #data_store: 0 ++ ++ # A boolean value that controls if server should be ejected temporarily when ++ # it fails consecutively server_failure_limit times. See liveness ++ # recommendations for information. Defaults to false. ++ #auto_eject_hosts: false ++ ++ # The timeout value in msec to wait for before retrying on a temporarily ++ # ejected server, when auto_eject_host is set to true. Defaults to 30000 msec. ++ #server_retry_timeout: 30000 ++ ++ # The number of consecutive failures on a server that would lead to it being ++ # temporarily ejected when auto_eject_host is set to true. Defaults to 2. ++ #server_failure_limit: 2 ++ ++ # A list of local server address, port and weight (name:port:weight or ++ # ip:port:weight) for this server pool. Currently, there is just one. ++ #servers: ++ # - name/ip:port ++ # - name/ip:port:weight ++ ++ # Encrypted communication. Must be one of 'none', 'rack', 'datacenter', or ++ # 'all'. Datacenter means all communication between datacenters is encrypted ++ # but within a datacenter it is not. Rack means all communication between ++ # racks and regions is encrypted however communication between nodes within ++ # the same rack is not encrypted. All means all communication between all ++ # nodes is encrypted. And none means none of the communication is encrypted. ++ #secure_server_option: ++ ++ # The address and port number for the REST endpoint and for accessing ++ # statistics. ++ #stats_listen: name/ip:port ++ ++ # Set stats aggregation interval in msec (default: 30000 msec). ++ #stats_interval: 30000 ++ ++ # Size of mbuf chunk in bytes (default: 16384 bytes). ++ #mbuf_size: 16384 ++ ++ # Max number of messages to allocate (default: 200000). ++ #max_msgs: 200000 ++ diff --git a/debian/patches/addFirewalldApplication.diff b/debian/patches/addFirewalldApplication.diff new file mode 100644 index 000000000..a991af4a4 --- /dev/null +++ b/debian/patches/addFirewalldApplication.diff @@ -0,0 +1,10 @@ +--- /dev/null ++++ b/dist/firewalld/dynomite.xml +@@ -0,0 +1,7 @@ ++ ++ ++ Dynomite ++ Generic dynamo implementation for different k-v storage engines. ++ ++ ++ diff --git a/debian/patches/addUWFApplication.diff b/debian/patches/addUWFApplication.diff new file mode 100644 index 000000000..a6003bf49 --- /dev/null +++ b/debian/patches/addUWFApplication.diff @@ -0,0 +1,7 @@ +--- /dev/null ++++ b/dist/ufw/dynomite +@@ -0,0 +1,4 @@ ++[Dynomite] ++title=Dynomite ++description=Generic dynamo implementation for different k-v storage engines. ++ports=8101,8102/tcp|22222/tcp diff --git a/debian/patches/fixUpstreamUpstartScript.diff b/debian/patches/fixUpstreamUpstartScript.diff new file mode 100644 index 000000000..f62e2ff7d --- /dev/null +++ b/debian/patches/fixUpstreamUpstartScript.diff @@ -0,0 +1,17 @@ +--- a/init/upstart_ubuntu__dynomite ++++ b/init/upstart_ubuntu__dynomite +@@ -17,11 +17,12 @@ + PATH=/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin + PIDFILE=/var/run/${NAME}.pid + CONFIG=/etc/dynomite/${NAME}.yml ++LOG=/var/log/${NAME}.log + INIT_OPTIONS=/etc/default/${NAME} + # RHEL specific file + #SYSTEM_CONFIG=/etc/sysconfig/${NAME} +-DAEMON=/usr/local/sbin/${NAME} +-DAEMON_OPTS="-d -c ${CONFIG} -p ${PIDFILE}" ++DAEMON=/usr/sbin/${NAME} ++DAEMON_OPTS="-d -c ${CONFIG} -p ${PIDFILE} -o ${LOG}" + # TODO: Runas USER + #USER="dynomite" + #GROUP="dynomite" diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 000000000..5c13599b3 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,4 @@ +fixUpstreamUpstartScript.diff +addFirewalldApplication.diff +addUWFApplication.diff +addDefaultConfig.diff diff --git a/debian/rules b/debian/rules new file mode 100755 index 000000000..7e030f990 --- /dev/null +++ b/debian/rules @@ -0,0 +1,8 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +%: + dh $@ --with=autoreconf diff --git a/debian/service b/debian/service new file mode 100644 index 000000000..f30bf5f36 --- /dev/null +++ b/debian/service @@ -0,0 +1,20 @@ +[Unit] +Description=Dynomite server +; Services that should be started before Dynomite +After=network.target nss-lookup.target time-sync.target +Documentation=man:dynomite(8) + +[Service] +User=dynomite +; Default environment variable values +Environment=DYNOMITE_CONF=/etc/dynomite/dynomite.yaml +Type=forking +; Environment vars to customize startup +EnvironmentFile=-/etc/default/dynomite +ExecStart=/usr/local/sbin/dynomite -d -c $DYNOMITE_CONF -p /var/run/dynomite/dynomite.pid +; Restart dynomite every 100ms +Restart=always +PIDFile=/var/run/dynomite/dynomite.pid + +[Install] +WantedBy=multi-user.target diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 000000000..163aaf8d8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt)