From b5445d3fae2fca61ed036a4e88f061903965db7a Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Thu, 22 Oct 2020 19:00:52 +0200 Subject: [BUILD] add systemd service file for dnbd3-server to installation targets --- CMakeLists.txt | 10 ++++-- conf/CMakeLists.txt | 13 -------- conf/alt-servers | 14 -------- conf/rpc.acl | 4 --- conf/server.conf | 71 ---------------------------------------- pkg/CMakeLists.txt | 7 ++++ pkg/config/CMakeLists.txt | 14 ++++++++ pkg/config/alt-servers | 14 ++++++++ pkg/config/rpc.acl | 4 +++ pkg/config/server.conf | 71 ++++++++++++++++++++++++++++++++++++++++ pkg/systemd/CMakeLists.txt | 12 +++++++ pkg/systemd/dnbd3-server.service | 12 +++++++ 12 files changed, 141 insertions(+), 105 deletions(-) delete mode 100644 conf/CMakeLists.txt delete mode 100644 conf/alt-servers delete mode 100644 conf/rpc.acl delete mode 100644 conf/server.conf create mode 100644 pkg/CMakeLists.txt create mode 100644 pkg/config/CMakeLists.txt create mode 100644 pkg/config/alt-servers create mode 100644 pkg/config/rpc.acl create mode 100644 pkg/config/server.conf create mode 100644 pkg/systemd/CMakeLists.txt create mode 100644 pkg/systemd/dnbd3-server.service diff --git a/CMakeLists.txt b/CMakeLists.txt index dae49c6..fcdc6b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,7 +161,11 @@ if(CMAKE_BUILD_TYPE MATCHES Release) "/lib/modules" "/lib/modules/${CMAKE_SYSTEM_VERSION}" "/lib/modules/${CMAKE_SYSTEM_VERSION}/extra" - "/etc") + "/etc" + "/usr" + "/usr/lib" + "/usr/lib/systemd" + "/usr/lib/systemd/system") if(DNBD3_KERNEL_MODULE) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/rpm/post "depmod -a\n") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/package/rpm/postun "depmod -a\n") @@ -195,5 +199,5 @@ endif(CMAKE_BUILD_TYPE MATCHES Release) # add all dnbd3 related projects from the source code directory add_subdirectory(src) -# add configuration files for packaging purposes -add_subdirectory(conf) +# add configuration and operational files for packaging purposes +add_subdirectory(pkg) diff --git a/conf/CMakeLists.txt b/conf/CMakeLists.txt deleted file mode 100644 index 1b888e6..0000000 --- a/conf/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.10) - -# set the project name -project(dnbd3-conf) - -# define all configuration files -set(DNBD3_CONF_FILES ${CMAKE_CURRENT_SOURCE_DIR}/alt-servers - ${CMAKE_CURRENT_SOURCE_DIR}/rpc.acl - ${CMAKE_CURRENT_SOURCE_DIR}/server.conf) - -# install configuration files into sample directory -install(FILES ${DNBD3_CONF_FILES} DESTINATION /etc/dnbd3-server/sample - COMPONENT server) diff --git a/conf/alt-servers b/conf/alt-servers deleted file mode 100644 index b26fe79..0000000 --- a/conf/alt-servers +++ /dev/null @@ -1,14 +0,0 @@ -[192.168.100.10] -comment=Some alt server - -[192.168.100.100] -comment=My first alt server that will not be used for replication -for=client -[192.168.100.50] -comment=Super sectret alt server that will be used for replication, but clients don't know about it -for=replication - -[192.168.100.123] -comment=Also just for replication, and only for images starting with foobar/baz/ -namespace=foobar/baz/ -for=replication diff --git a/conf/rpc.acl b/conf/rpc.acl deleted file mode 100644 index b2c2c44..0000000 --- a/conf/rpc.acl +++ /dev/null @@ -1,4 +0,0 @@ -# Everything from localhost -127.0.0.0/8 ALL -# Some info reading for another machine -132.230.8.113 STATS CLIENT_LIST IMAGE_LIST diff --git a/conf/server.conf b/conf/server.conf deleted file mode 100644 index 5f0b2a0..0000000 --- a/conf/server.conf +++ /dev/null @@ -1,71 +0,0 @@ -[dnbd3] -; port to listen on (default: 5003) -listenPort=5003 -; relative root directory for images, ending in .r[1-9][0-9]* -basePath=/mnt/storage -; artificial connection delay for connecting servers -serverPenalty=100000 -; artificial connection delay for connecting clients -clientPenalty=0 -; is this server a proxy? if true, requests for non-existing images will be relayed to known alt-servers -isProxy=true -; if proxy is true and an image is incomplete, should idle bandwidth be used to replicate missing blocks? -backgroundReplication=true -; minimum amount of connected clients for background replication to kick in -bgrMinClients=0 -; if another proxy requests and image that we don't have, should we ask our alt-servers for it? -lookupMissingForProxy=true -; create sparse files instead of preallocating; ignored if backgroundReplication=true -; -- only recommended if cache space is small -sparseFiles=false -; if true (which is the default), images will automatically be removed from the list if they can't be accessed -removeMissingImages=true -; timeout in ms for send/recv on connections to uplink servers (used for replication) -uplinkTimeout=1250 -; timeout in ms for send/recv on connections to clients (using an image on this server) -clientTimeout=15000 -; set this to true to close handles of unused images after some timeout -closeUnusedFd=false -; set this to true to load files without the .r[0-9]+ extension too, assuming RID=1 -vmdkLegacyMode=false -; Don't set the server flag when connecting to alt-servers -; Intended for if the proxy is used for on-client caching -pretendClient=false -; When running in proxy mode and running out of space, automatically delete oldest image(s) to make -; the newly replicated image fit. In sparse mode, this will make sure at least 2GB of free space are -; available when replicating a new image. During normal operation, it will free at least 256MB whenever -; an attempt to write more data to cache fails. In non-sparse mode, whenever a new image is replicated, -; as much space as is required to store the entire image will be made available. -; However, after startup the proxy will refuse to delete any images for the time span given below, to be -; able to gather up to date usage information for the images available. If unitless, the value is -; interpreted in seconds. Valid suffixes are m, h, d. -; Setting this to -1 disables deletion of images. If the cache partition is full, no more images will -; be replicated unless you manually free up more disk space. -autoFreeDiskSpaceDelay=10h - -[limits] -maxClients=2000 -maxImages=1000 -maxPayload=9M -maxReplicationSize=150G - -; Log related config -[logging] -; log file path and name -; comment out to disable logging to file -; protip: use SIGUSR2 to reopen log file -file=./dnbd3.log -; which type of messages to log to file -fileMask=ERROR WARNING MINOR INFO DEBUG1 -; which to log to console (stdout) -consoleMask=ERROR WARNING MINOR INFO -; Valid types (warning: specifying invalid types will not yield an error!) -; ERROR Fatal error, server will terminate -; WARNING Major issue, something is broken but keep running -; MINOR Minor issue, more of a hickup than serious problem -; INFO Informational message -; DEBUG1 Debug information, used for medium verbosity -; DEBUG2 Used for debug messages that would show up a lot -; -; Whether timestamps should be output to console too (or just to file if false) -consoleTimestamps=false diff --git a/pkg/CMakeLists.txt b/pkg/CMakeLists.txt new file mode 100644 index 0000000..3112696 --- /dev/null +++ b/pkg/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.10) + +# set the project name +project(dnbd3-pkg) + +add_subdirectory(config) +add_subdirectory(systemd) diff --git a/pkg/config/CMakeLists.txt b/pkg/config/CMakeLists.txt new file mode 100644 index 0000000..1d553db --- /dev/null +++ b/pkg/config/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.10) + +# set the project name +project(dnbd3-config) + +# define all configuration files +set(DNBD3_CONFIG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/alt-servers + ${CMAKE_CURRENT_SOURCE_DIR}/rpc.acl + ${CMAKE_CURRENT_SOURCE_DIR}/server.conf) + +# install configuration files into sample directory +install(FILES ${DNBD3_CONFIG_FILES} + DESTINATION /etc/dnbd3-server/sample + COMPONENT server) diff --git a/pkg/config/alt-servers b/pkg/config/alt-servers new file mode 100644 index 0000000..b26fe79 --- /dev/null +++ b/pkg/config/alt-servers @@ -0,0 +1,14 @@ +[192.168.100.10] +comment=Some alt server + +[192.168.100.100] +comment=My first alt server that will not be used for replication +for=client +[192.168.100.50] +comment=Super sectret alt server that will be used for replication, but clients don't know about it +for=replication + +[192.168.100.123] +comment=Also just for replication, and only for images starting with foobar/baz/ +namespace=foobar/baz/ +for=replication diff --git a/pkg/config/rpc.acl b/pkg/config/rpc.acl new file mode 100644 index 0000000..b2c2c44 --- /dev/null +++ b/pkg/config/rpc.acl @@ -0,0 +1,4 @@ +# Everything from localhost +127.0.0.0/8 ALL +# Some info reading for another machine +132.230.8.113 STATS CLIENT_LIST IMAGE_LIST diff --git a/pkg/config/server.conf b/pkg/config/server.conf new file mode 100644 index 0000000..5f0b2a0 --- /dev/null +++ b/pkg/config/server.conf @@ -0,0 +1,71 @@ +[dnbd3] +; port to listen on (default: 5003) +listenPort=5003 +; relative root directory for images, ending in .r[1-9][0-9]* +basePath=/mnt/storage +; artificial connection delay for connecting servers +serverPenalty=100000 +; artificial connection delay for connecting clients +clientPenalty=0 +; is this server a proxy? if true, requests for non-existing images will be relayed to known alt-servers +isProxy=true +; if proxy is true and an image is incomplete, should idle bandwidth be used to replicate missing blocks? +backgroundReplication=true +; minimum amount of connected clients for background replication to kick in +bgrMinClients=0 +; if another proxy requests and image that we don't have, should we ask our alt-servers for it? +lookupMissingForProxy=true +; create sparse files instead of preallocating; ignored if backgroundReplication=true +; -- only recommended if cache space is small +sparseFiles=false +; if true (which is the default), images will automatically be removed from the list if they can't be accessed +removeMissingImages=true +; timeout in ms for send/recv on connections to uplink servers (used for replication) +uplinkTimeout=1250 +; timeout in ms for send/recv on connections to clients (using an image on this server) +clientTimeout=15000 +; set this to true to close handles of unused images after some timeout +closeUnusedFd=false +; set this to true to load files without the .r[0-9]+ extension too, assuming RID=1 +vmdkLegacyMode=false +; Don't set the server flag when connecting to alt-servers +; Intended for if the proxy is used for on-client caching +pretendClient=false +; When running in proxy mode and running out of space, automatically delete oldest image(s) to make +; the newly replicated image fit. In sparse mode, this will make sure at least 2GB of free space are +; available when replicating a new image. During normal operation, it will free at least 256MB whenever +; an attempt to write more data to cache fails. In non-sparse mode, whenever a new image is replicated, +; as much space as is required to store the entire image will be made available. +; However, after startup the proxy will refuse to delete any images for the time span given below, to be +; able to gather up to date usage information for the images available. If unitless, the value is +; interpreted in seconds. Valid suffixes are m, h, d. +; Setting this to -1 disables deletion of images. If the cache partition is full, no more images will +; be replicated unless you manually free up more disk space. +autoFreeDiskSpaceDelay=10h + +[limits] +maxClients=2000 +maxImages=1000 +maxPayload=9M +maxReplicationSize=150G + +; Log related config +[logging] +; log file path and name +; comment out to disable logging to file +; protip: use SIGUSR2 to reopen log file +file=./dnbd3.log +; which type of messages to log to file +fileMask=ERROR WARNING MINOR INFO DEBUG1 +; which to log to console (stdout) +consoleMask=ERROR WARNING MINOR INFO +; Valid types (warning: specifying invalid types will not yield an error!) +; ERROR Fatal error, server will terminate +; WARNING Major issue, something is broken but keep running +; MINOR Minor issue, more of a hickup than serious problem +; INFO Informational message +; DEBUG1 Debug information, used for medium verbosity +; DEBUG2 Used for debug messages that would show up a lot +; +; Whether timestamps should be output to console too (or just to file if false) +consoleTimestamps=false diff --git a/pkg/systemd/CMakeLists.txt b/pkg/systemd/CMakeLists.txt new file mode 100644 index 0000000..d1e5087 --- /dev/null +++ b/pkg/systemd/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.10) + +# set the project name +project(dnbd3-systemd) + +# define all systemd related files +set(DNBD3_SYSTEMD_FILES ${CMAKE_CURRENT_SOURCE_DIR}/dnbd3-server.service) + +# install systemd service files +install(FILES ${DNBD3_SYSTEMD_FILES} + DESTINATION /usr/lib/systemd/system + COMPONENT server) diff --git a/pkg/systemd/dnbd3-server.service b/pkg/systemd/dnbd3-server.service new file mode 100644 index 0000000..de800ce --- /dev/null +++ b/pkg/systemd/dnbd3-server.service @@ -0,0 +1,12 @@ +[Unit] +Description=DNBD3 server +Wants=network-online.target +After=network-online.target + +[Service] +Type=simple +ExecStart=/usr/bin/dnbd3-server -n -c /etc/dnbd3-server +Restart=on-failure + +[Install] +WantedBy=multi-user.target -- cgit v1.2.3-55-g7522