summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZ. Liu <clan@users.noreply.github.com>2021-01-28 17:12:39 +0800
committerGitHub <noreply@github.com>2021-01-28 11:12:39 +0200
commit17b34c73091968a5a37a267f69563c155efe8ce4 (patch)
treed0876aa502e0c7ea981276bf24508d6d879c752e
parent3a5049042ac06b6ed5e526f331d5378bf7c7b7ed (diff)
downloadredis-17b34c73091968a5a37a267f69563c155efe8ce4.tar.gz
Add 'set-proc-title' config so that this mechanism can be disabled (#3623)
if option `set-proc-title' is no, then do nothing for proc title. The reason has been explained long ago, see following: We update redis to 2.8.8, then found there are some side effect when redis always change the process title. We run several slave instance on one computer, and all these salves listen on unix socket only, then ps will show: 1 S redis 18036 1 0 80 0 - 56130 ep_pol 14:02 ? 00:00:31 /usr/sbin/redis-server *:0 1 S redis 23949 1 0 80 0 - 11074 ep_pol 15:41 ? 00:00:00 /usr/sbin/redis-server *:0 for redis 2.6 the output of ps is like following: 1 S redis 18036 1 0 80 0 - 56130 ep_pol 14:02 ? 00:00:31 /usr/sbin/redis-server /etc/redis/a.conf 1 S redis 23949 1 0 80 0 - 11074 ep_pol 15:41 ? 00:00:00 /usr/sbin/redis-server /etc/redis/b.conf Later is more informational in our case. The situation is worse when we manage the config and process running state by salt. Salt check the process by running "ps | grep SIG" (for Gentoo System) to check the running state, where SIG is the string to search for when looking for the service process with ps. Previously, we define sig as "/usr/sbin/redis-server /etc/redis/a.conf". Since the ps output is identical for our case, so we have no way to check the state of specified redis instance. So, for our case, we prefer the old behavior, i.e, do not change the process title for the main redis process. Or add an option such as "set-proc-title [yes|no]" to control this behavior. Co-authored-by: Yossi Gottlieb <yossigo@gmail.com> Co-authored-by: Oran Agra <oran@redislabs.com>
-rw-r--r--redis.conf5
-rw-r--r--src/config.c1
-rw-r--r--src/server.c2
-rw-r--r--src/server.h1
-rw-r--r--tests/unit/introspection.tcl1
5 files changed, 9 insertions, 1 deletions
diff --git a/redis.conf b/redis.conf
index a131b406f..370542344 100644
--- a/redis.conf
+++ b/redis.conf
@@ -325,6 +325,11 @@ databases 16
# ASCII art logo in startup logs by setting the following option to yes.
always-show-logo no
+# By default, Redis modifies the process title (as seen in 'top' and 'ps') to
+# provide some runtime information. It is possible to disable this and leave
+# the process name as executed by setting the following to no.
+set-proc-title yes
+
################################ SNAPSHOTTING ################################
# Save the DB to disk.
diff --git a/src/config.c b/src/config.c
index 5db08f8bc..20d432573 100644
--- a/src/config.c
+++ b/src/config.c
@@ -2388,6 +2388,7 @@ standardConfig configs[] = {
createBoolConfig("rdb-del-sync-files", NULL, MODIFIABLE_CONFIG, server.rdb_del_sync_files, 0, NULL, NULL),
createBoolConfig("activerehashing", NULL, MODIFIABLE_CONFIG, server.activerehashing, 1, NULL, NULL),
createBoolConfig("stop-writes-on-bgsave-error", NULL, MODIFIABLE_CONFIG, server.stop_writes_on_bgsave_err, 1, NULL, NULL),
+ createBoolConfig("set-proc-title", NULL, IMMUTABLE_CONFIG, server.set_proc_title, 1, NULL, NULL), /* Should setproctitle be used? */
createBoolConfig("dynamic-hz", NULL, MODIFIABLE_CONFIG, server.dynamic_hz, 1, NULL, NULL), /* Adapt hz to # of clients.*/
createBoolConfig("lazyfree-lazy-eviction", NULL, MODIFIABLE_CONFIG, server.lazyfree_lazy_eviction, 0, NULL, NULL),
createBoolConfig("lazyfree-lazy-expire", NULL, MODIFIABLE_CONFIG, server.lazyfree_lazy_expire, 0, NULL, NULL),
diff --git a/src/server.c b/src/server.c
index a0badea87..ce34af3df 100644
--- a/src/server.c
+++ b/src/server.c
@@ -5919,7 +5919,7 @@ int main(int argc, char **argv) {
readOOMScoreAdj();
initServer();
if (background || server.pidfile) createPidFile();
- redisSetProcTitle(argv[0]);
+ if (server.set_proc_title) redisSetProcTitle(argv[0]);
redisAsciiArt();
checkTcpBacklogSettings();
diff --git a/src/server.h b/src/server.h
index 83e007ebe..b72d7bd0d 100644
--- a/src/server.h
+++ b/src/server.h
@@ -1297,6 +1297,7 @@ struct redisServer {
int supervised; /* 1 if supervised, 0 otherwise. */
int supervised_mode; /* See SUPERVISED_* */
int daemonize; /* True if running as a daemon */
+ int set_proc_title; /* True if change proc title */
clientBufferLimitsConfig client_obuf_limits[CLIENT_TYPE_OBUF_COUNT];
/* AOF persistence */
int aof_enabled; /* AOF configuration */
diff --git a/tests/unit/introspection.tcl b/tests/unit/introspection.tcl
index 0a7f7a9c9..ba28341ff 100644
--- a/tests/unit/introspection.tcl
+++ b/tests/unit/introspection.tcl
@@ -112,6 +112,7 @@ start_server {tags {"introspection"}} {
bio_cpulist
aof_rewrite_cpulist
bgsave_cpulist
+ set-proc-title
}
if {!$::tls} {