开始请求重复得太快

时间:2016-02-17 09:26:25

标签: systemd

我正在写一个bash脚本,但我经常面对这个问题。 当我尝试startstop我经常获得的服务时:

start request repeated too quickly 

我该如何解决这个问题? 例如,当我尝试重启docker或openshift-origin master时。

sudo service origin-master restart

● origin-master.service - Origin Master Service
   Loaded: loaded (/usr/lib/systemd/system/origin-master.service; enabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Wed 2016-02-17 08:22:11 UTC; 44s ago
     Docs: https://github.com/openshift/origin
  Process: 2296 ExecStart=/usr/bin/openshift start master --config=${CONFIG_FILE} $OPTIONS (code=exited, status=255)
 Main PID: 2296 (code=exited, status=255)

Feb 17 08:22:10 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: origin-master.service: main process exited, code=exited, status=255/n/a
Feb 17 08:22:10 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: Failed to start Origin Master Service.
Feb 17 08:22:10 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: Unit origin-master.service entered failed state.
Feb 17 08:22:10 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: origin-master.service failed.
Feb 17 08:22:11 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: origin-master.service holdoff time over, scheduling restart.
Feb 17 08:22:11 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: start request repeated too quickly for origin-master.service
Feb 17 08:22:11 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: Failed to start Origin Master Service.
Feb 17 08:22:11 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: Unit origin-master.service entered failed state.
Feb 17 08:22:11 ip-172-xx-xx-xx.eu-central-1.compute.internal systemd[1]: origin-master.service failed.

我的脚本正在做:

if [ $1 = "-u" ]
then
 sudo service origin-master restart
fi

在我执行脚本之前,可以手动重启。但在它之后它仍然给出了错误

3 个答案:

答案 0 :(得分:5)

这是systemctl的“功能”。文件中有一个参数,以秒为单位限制重启频率。在测试时降低它。

编辑文件 /etc/systemd/system/multi-user.target.wants/<your service here>

我的示例:

Restart=on-failure
StartLimitBurst=2
# Restart, but not more than once every 10 minutes
#StartLimitInterval=600
# Restart, but not more than once every 30s (for testing purposes)
StartLimitInterval=30

答案 1 :(得分:1)

我在 Ubuntu 20.4 上遇到了这个问题。并且通过向 ExecStart 文件添加执行权限,问题得到解决。

from myfile import TestClass

test_class = TestClass()
test_class.func1()

答案 2 :(得分:-1)

我建议你熟悉systemd。当您运行service时,这就是您在引擎盖下使用的内容。正如@chepner所说,服务失败(正如你从日志的第二行看到的那样),它的重启速度太快,触发了错误。

尝试运行journalctl -u origin-master.service以找出错误发生的原因。

此外,systemd cat origin-master.service会显示描述您服务的服务单位文件 - 可能存在错误。