|
|
572a44 |
From 409dbe76d743448629167f4412f290bba1aae11e Mon Sep 17 00:00:00 2001
|
|
|
a4b143 |
From: Lukas Nykryn <lnykryn@redhat.com>
|
|
|
a4b143 |
Date: Fri, 8 Nov 2013 16:01:22 +0100
|
|
|
a4b143 |
Subject: [PATCH] manager: configurable StartLimit default values
|
|
|
a4b143 |
|
|
|
a4b143 |
https://bugzilla.redhat.com/show_bug.cgi?id=821723
|
|
|
a4b143 |
---
|
|
|
a4b143 |
man/systemd-system.conf.xml | 13 +++++++++++++
|
|
|
a4b143 |
man/systemd.service.xml | 9 ++++++---
|
|
|
a4b143 |
src/core/main.c | 6 ++++++
|
|
|
a4b143 |
src/core/manager.h | 3 +++
|
|
|
a4b143 |
src/core/service.c | 4 +++-
|
|
|
a4b143 |
src/core/system.conf | 2 ++
|
|
|
a4b143 |
src/core/user.conf | 2 ++
|
|
|
a4b143 |
src/shared/def.h | 3 +++
|
|
|
a4b143 |
8 files changed, 38 insertions(+), 4 deletions(-)
|
|
|
a4b143 |
|
|
|
a4b143 |
diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml
|
|
|
a4b143 |
index c1f2648..9a1a99f 100644
|
|
|
a4b143 |
--- a/man/systemd-system.conf.xml
|
|
|
a4b143 |
+++ b/man/systemd-system.conf.xml
|
|
|
a4b143 |
@@ -115,6 +115,19 @@
|
|
|
a4b143 |
<varname>TimeoutSec=</varname> value.
|
|
|
a4b143 |
</para></listitem>
|
|
|
a4b143 |
</varlistentry>
|
|
|
a4b143 |
+ <varlistentry>
|
|
|
a4b143 |
+ <term><varname>DefaultStartLimitInterval=</varname></term>
|
|
|
a4b143 |
+ <term><varname>DefaultStartLimitBurst=</varname></term>
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ <listitem><para>Configure the default start rate
|
|
|
a4b143 |
+ limiting, as configured per-service by
|
|
|
a4b143 |
+ <varname>StartLimitInterval=</varname> and
|
|
|
a4b143 |
+ <varname>StartLimitBurst=</varname>. See
|
|
|
a4b143 |
+ <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
|
|
a4b143 |
+ for details on the per-service
|
|
|
a4b143 |
+ settings).
|
|
|
a4b143 |
+ </para></listitem>
|
|
|
a4b143 |
+ </varlistentry>
|
|
|
a4b143 |
|
|
|
a4b143 |
<varlistentry>
|
|
|
a4b143 |
<term><varname>CPUAffinity=</varname></term>
|
|
|
a4b143 |
diff --git a/man/systemd.service.xml b/man/systemd.service.xml
|
|
|
572a44 |
index df04048..3f31c11 100644
|
|
|
a4b143 |
--- a/man/systemd.service.xml
|
|
|
a4b143 |
+++ b/man/systemd.service.xml
|
|
|
572a44 |
@@ -863,12 +863,15 @@
|
|
|
a4b143 |
these two options, this rate limiting
|
|
|
a4b143 |
may be modified. Use
|
|
|
a4b143 |
<varname>StartLimitInterval=</varname>
|
|
|
a4b143 |
- to configure the checking interval
|
|
|
a4b143 |
- (defaults to 10s, set to 0 to disable
|
|
|
a4b143 |
+ to configure the checking interval (defaults to
|
|
|
a4b143 |
+ <varname>DefaultStartLimitInterval=</varname> in
|
|
|
a4b143 |
+ manager configuration file, set to 0 to disable
|
|
|
a4b143 |
any kind of rate limiting). Use
|
|
|
a4b143 |
<varname>StartLimitBurst=</varname> to
|
|
|
a4b143 |
configure how many starts per interval
|
|
|
a4b143 |
- are allowed (defaults to 5). These
|
|
|
a4b143 |
+ are allowed (defaults to
|
|
|
a4b143 |
+ <varname>DefaultStartLimitBurst=</varname> in
|
|
|
a4b143 |
+ manager configuration file). These
|
|
|
a4b143 |
configuration options are particularly
|
|
|
a4b143 |
useful in conjunction with
|
|
|
a4b143 |
<varname>Restart=</varname>, however
|
|
|
a4b143 |
diff --git a/src/core/main.c b/src/core/main.c
|
|
|
572a44 |
index 937994c..00fd394 100644
|
|
|
a4b143 |
--- a/src/core/main.c
|
|
|
a4b143 |
+++ b/src/core/main.c
|
|
|
a4b143 |
@@ -93,6 +93,8 @@ static ExecOutput arg_default_std_error = EXEC_OUTPUT_INHERIT;
|
|
|
a4b143 |
static usec_t arg_default_restart_usec = DEFAULT_RESTART_USEC;
|
|
|
a4b143 |
static usec_t arg_default_timeout_start_usec = DEFAULT_TIMEOUT_USEC;
|
|
|
a4b143 |
static usec_t arg_default_timeout_stop_usec = DEFAULT_TIMEOUT_USEC;
|
|
|
a4b143 |
+static usec_t arg_default_start_limit_interval = DEFAULT_START_LIMIT_INTERVAL;
|
|
|
a4b143 |
+static unsigned arg_default_start_limit_burst = DEFAULT_START_LIMIT_BURST;
|
|
|
a4b143 |
static usec_t arg_runtime_watchdog = 0;
|
|
|
a4b143 |
static usec_t arg_shutdown_watchdog = 10 * USEC_PER_MINUTE;
|
|
|
a4b143 |
static char **arg_default_environment = NULL;
|
|
|
a4b143 |
@@ -642,6 +644,8 @@ static int parse_config_file(void) {
|
|
|
a4b143 |
{ "Manager", "DefaultTimeoutStartSec", config_parse_sec, 0, &arg_default_timeout_start_usec },
|
|
|
a4b143 |
{ "Manager", "DefaultTimeoutStopSec", config_parse_sec, 0, &arg_default_timeout_stop_usec },
|
|
|
a4b143 |
{ "Manager", "DefaultRestartSec", config_parse_sec, 0, &arg_default_restart_usec },
|
|
|
a4b143 |
+ { "Manager", "DefaultStartLimitInterval", config_parse_sec, 0, &arg_default_start_limit_interval },
|
|
|
a4b143 |
+ { "Manager", "DefaultStartLimitBurst", config_parse_unsigned, 0, &arg_default_start_limit_burst },
|
|
|
a4b143 |
{ "Manager", "JoinControllers", config_parse_join_controllers, 0, &arg_join_controllers },
|
|
|
a4b143 |
{ "Manager", "RuntimeWatchdogSec", config_parse_sec, 0, &arg_runtime_watchdog },
|
|
|
a4b143 |
{ "Manager", "ShutdownWatchdogSec", config_parse_sec, 0, &arg_shutdown_watchdog },
|
|
|
a4b143 |
@@ -1551,6 +1555,8 @@ int main(int argc, char *argv[]) {
|
|
|
a4b143 |
m->default_restart_usec = arg_default_restart_usec;
|
|
|
a4b143 |
m->default_timeout_start_usec = arg_default_timeout_start_usec;
|
|
|
a4b143 |
m->default_timeout_stop_usec = arg_default_timeout_stop_usec;
|
|
|
a4b143 |
+ m->default_start_limit_interval = arg_default_start_limit_interval;
|
|
|
a4b143 |
+ m->default_start_limit_burst = arg_default_start_limit_burst;
|
|
|
a4b143 |
m->runtime_watchdog = arg_runtime_watchdog;
|
|
|
a4b143 |
m->shutdown_watchdog = arg_shutdown_watchdog;
|
|
|
a4b143 |
m->userspace_timestamp = userspace_timestamp;
|
|
|
a4b143 |
diff --git a/src/core/manager.h b/src/core/manager.h
|
|
|
a4b143 |
index e74c609..ee42c5e 100644
|
|
|
a4b143 |
--- a/src/core/manager.h
|
|
|
a4b143 |
+++ b/src/core/manager.h
|
|
|
a4b143 |
@@ -233,6 +233,9 @@ struct Manager {
|
|
|
a4b143 |
usec_t default_restart_usec, default_timeout_start_usec,
|
|
|
a4b143 |
default_timeout_stop_usec;
|
|
|
a4b143 |
|
|
|
a4b143 |
+ usec_t default_start_limit_interval;
|
|
|
a4b143 |
+ unsigned default_start_limit_burst;
|
|
|
a4b143 |
+
|
|
|
a4b143 |
struct rlimit *rlimit[RLIMIT_NLIMITS];
|
|
|
a4b143 |
|
|
|
a4b143 |
/* non-zero if we are reloading or reexecuting, */
|
|
|
a4b143 |
diff --git a/src/core/service.c b/src/core/service.c
|
|
|
572a44 |
index e81aa1f..5662180 100644
|
|
|
a4b143 |
--- a/src/core/service.c
|
|
|
a4b143 |
+++ b/src/core/service.c
|
|
|
a4b143 |
@@ -143,7 +143,9 @@ static void service_init(Unit *u) {
|
|
|
a4b143 |
kill_context_init(&s->kill_context);
|
|
|
a4b143 |
cgroup_context_init(&s->cgroup_context);
|
|
|
a4b143 |
|
|
|
a4b143 |
- RATELIMIT_INIT(s->start_limit, 10*USEC_PER_SEC, 5);
|
|
|
a4b143 |
+ RATELIMIT_INIT(s->start_limit,
|
|
|
a4b143 |
+ u->manager->default_start_limit_interval,
|
|
|
a4b143 |
+ u->manager->default_start_limit_burst);
|
|
|
a4b143 |
|
|
|
a4b143 |
s->control_command_id = _SERVICE_EXEC_COMMAND_INVALID;
|
|
|
a4b143 |
}
|
|
|
a4b143 |
diff --git a/src/core/system.conf b/src/core/system.conf
|
|
|
a4b143 |
index 3c6cc03..38bbca5 100644
|
|
|
a4b143 |
--- a/src/core/system.conf
|
|
|
a4b143 |
+++ b/src/core/system.conf
|
|
|
a4b143 |
@@ -27,6 +27,8 @@
|
|
|
a4b143 |
#DefaultTimeoutStartSec=90s
|
|
|
a4b143 |
#DefaultTimeoutStopSec=90s
|
|
|
a4b143 |
#DefaultRestartSec=100ms
|
|
|
a4b143 |
+#DefaultStartLimitInterval=10s
|
|
|
a4b143 |
+#DefaultStartLimitBurst=5
|
|
|
a4b143 |
#DefaultEnvironment=
|
|
|
a4b143 |
#DefaultLimitCPU=
|
|
|
a4b143 |
#DefaultLimitFSIZE=
|
|
|
a4b143 |
diff --git a/src/core/user.conf b/src/core/user.conf
|
|
|
a4b143 |
index b030701..923ca66 100644
|
|
|
a4b143 |
--- a/src/core/user.conf
|
|
|
a4b143 |
+++ b/src/core/user.conf
|
|
|
a4b143 |
@@ -17,3 +17,5 @@
|
|
|
a4b143 |
#DefaultTimeoutStartSec=90s
|
|
|
a4b143 |
#DefaultTimeoutStopSec=90s
|
|
|
a4b143 |
#DefaultRestartSec=100ms
|
|
|
a4b143 |
+#DefaultStartLimitInterval=10s
|
|
|
a4b143 |
+#DefaultStartLimitBurst=5
|
|
|
a4b143 |
diff --git a/src/shared/def.h b/src/shared/def.h
|
|
|
a4b143 |
index edd0bcf..e4ef735 100644
|
|
|
a4b143 |
--- a/src/shared/def.h
|
|
|
a4b143 |
+++ b/src/shared/def.h
|
|
|
a4b143 |
@@ -27,6 +27,9 @@
|
|
|
a4b143 |
#define DEFAULT_RESTART_USEC (100*USEC_PER_MSEC)
|
|
|
a4b143 |
#define DEFAULT_CONFIRM_USEC (30*USEC_PER_SEC)
|
|
|
a4b143 |
|
|
|
a4b143 |
+#define DEFAULT_START_LIMIT_INTERVAL (10*USEC_PER_SEC)
|
|
|
a4b143 |
+#define DEFAULT_START_LIMIT_BURST 5
|
|
|
a4b143 |
+
|
|
|
a4b143 |
#define DEFAULT_EXIT_USEC (5*USEC_PER_MINUTE)
|
|
|
a4b143 |
|
|
|
a4b143 |
#define SYSTEMD_CGROUP_CONTROLLER "name=systemd"
|