diff options
author | Salvatore Sanfilippo <antirez@gmail.com> | 2019-12-19 08:54:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-19 08:54:22 +0100 |
commit | f4b81970601ee138af13f66d62ad10eabe56f41c (patch) | |
tree | b2ed034097b878a44a74a77b764b95b10e9e5b97 /utils | |
parent | c5bc1c14c0bfb5213b230a1d0dd96c5f24341885 (diff) | |
parent | c7b68d10ea6137305715d2660897237a864c552e (diff) | |
download | redis-f4b81970601ee138af13f66d62ad10eabe56f41c.tar.gz |
Merge pull request #6052 from jtru/better-systemd-integration-v2
Better systemd integration v2
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/install_server.sh | 10 | ||||
-rw-r--r-- | utils/systemd-redis_multiple_servers@.service | 37 | ||||
-rw-r--r-- | utils/systemd-redis_server.service | 41 |
3 files changed, 88 insertions, 0 deletions
diff --git a/utils/install_server.sh b/utils/install_server.sh index 8e5753bc6..efda7da1c 100755 --- a/utils/install_server.sh +++ b/utils/install_server.sh @@ -73,6 +73,16 @@ if [ "$(id -u)" -ne 0 ] ; then exit 1 fi +#bail if this system is managed by systemd +_pid_1_exe="$(readlink -f /proc/1/exe)" +if [ "${_pid_1_exe##*/}" = systemd ] +then + echo "This systems seems to use systemd." + echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!" + exit 1 +fi +unset _pid_1_exe + if ! echo $REDIS_PORT | egrep -q '^[0-9]+$' ; then _MANUAL_EXECUTION=true #Read the redis port diff --git a/utils/systemd-redis_multiple_servers@.service b/utils/systemd-redis_multiple_servers@.service new file mode 100644 index 000000000..108ccfc64 --- /dev/null +++ b/utils/systemd-redis_multiple_servers@.service @@ -0,0 +1,37 @@ +# example systemd template service unit file for multiple redis-servers +# +# You can use this file as a blueprint for your actual template service unit +# file, if you intend to run multiple independent redis-server instances in +# parallel using systemd's "template unit files" feature. If you do, you will +# want to choose a better basename for your service unit by renaming this file +# when copying it. +# +# Please take a look at the provided "systemd-redis_server.service" example +# service unit file, too, if you choose to use this approach at managing +# multiple redis-server instances via systemd. + +[Unit] +Description=Redis data structure server - instance %i +Documentation=https://redis.io/documentation +# This template unit assumes your redis-server configuration file(s) +# to live at /etc/redis/redis_server_<INSTANCE_NAME>.conf +AssertPathExists=/etc/redis/redis_server_%i.conf +#Before=your_application.service another_example_application.service +#AssertPathExists=/var/lib/redis + +[Service] +ExecStart=/usr/local/bin/redis-server /etc/redis/redis_server_%i.conf +LimitNOFILE=10032 +NoNewPrivileges=yes +#OOMScoreAdjust=-900 +#PrivateTmp=yes +Type=notify +TimeoutStartSec=infinity +TimeoutStopSec=infinity +UMask=0077 +#User=redis +#Group=redis +#WorkingDirectory=/var/lib/redis + +[Install] +WantedBy=multi-user.target diff --git a/utils/systemd-redis_server.service b/utils/systemd-redis_server.service new file mode 100644 index 000000000..addee3498 --- /dev/null +++ b/utils/systemd-redis_server.service @@ -0,0 +1,41 @@ +# example systemd service unit file for redis-server +# +# In order to use this as a template for providing a redis service in your +# environment, _at the very least_ make sure to adapt the redis configuration +# file you intend to use as needed (make sure to set "supervised systemd"), and +# to set sane TimeoutStartSec and TimeoutStopSec property values in the unit's +# "[Service]" section to fit your needs. +# +# Some properties, such as User= and Group=, are highly desirable for virtually +# all deployments of redis, but cannot be provided in a manner that fits all +# expectable environments. Some of these properties have been commented out in +# this example service unit file, but you are highly encouraged to set them to +# fit your needs. +# +# Please refer to systemd.unit(5), systemd.service(5), and systemd.exec(5) for +# more information. + +[Unit] +Description=Redis data structure server +Documentation=https://redis.io/documentation +#Before=your_application.service another_example_application.service +#AssertPathExists=/var/lib/redis + +[Service] +ExecStart=/usr/local/bin/redis-server --supervised systemd --daemonize no +## Alternatively, have redis-server load a configuration file: +#ExecStart=/usr/local/bin/redis-server /path/to/your/redis.conf +LimitNOFILE=10032 +NoNewPrivileges=yes +#OOMScoreAdjust=-900 +#PrivateTmp=yes +Type=notify +TimeoutStartSec=infinity +TimeoutStopSec=infinity +UMask=0077 +#User=redis +#Group=redis +#WorkingDirectory=/var/lib/redis + +[Install] +WantedBy=multi-user.target |