Fabric的sudo('service httpd start')不起作用

时间:2014-10-24 16:26:32

标签: apache amazon-ec2 fabric

[1]我执行了Fabric的sudo('service httpd start')。

[chikaram] sudo: service https start
[chikaram] out: Starting httpd:                       [  OK  ]

[2]但我的网页仍在关闭!

[3]所以我检查了EC2上的httpd状态

[ec2-user ~]$ sudo service httpd status
httpd dead but subsys locked

[4]然后我在EC2上启动了httpd。

[ec2-user ~]$ sudo service httpd start
Starting httpd:                                       [  OK  ]

[ec2-user ~]$ sudo service httpd status
httpd (pid  25217) is running...

我已经尝试了很多次但结果总是一样。

  • Fabric的sudo('service httpd start')失败,并显示消息“httpd dead但subsys locked。”
  • EC2上的“sudo service httpd status”。

截至目前,我正在做:local('ssh chikaram“sudo service httpd start”')

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题,并在下面解决了。

这是我的解决方法。

sudo('service %s restart && sleep 5' % service,)

如果服务重启返回码为零,该程序将重启上面定义的某些服务(如nginx)并等待5秒。

我猜根本原因是在fork未完成之前,结构会话已关闭。