2012-07-05 67 views
5

我有一个命令service app start-demo需要我在命令行中键入sudo service app start-demo作为sudo在织物中执行

我用sudo(service app start-demo)sudo(sudo service app start-demo)但是我还是

警告:sudo的()在执行时遇到错误(返回码1)“sudo的服务应用程序启动演示”

我有执行没问题作为终端中的命令行。

我不确定SADeprecationWarning:是否构成织物失败?

谢谢。


[email protected]:/var/lib/app$ fab kickstart 
You are installing prereqs.......... 
### Install Prereqs for Populate ### 
No hosts found. Please specify (single) host string for connection: localhost 
[localhost] Login password: 

### I am starting demo ### 
[localhost] sudo: sudo service app start-demo 
[localhost] out: Starting demo 

Fatal error: sudo() encountered an error (return code 1) while executing 'sudo service app start-demo' 

Aborting. 
Disconnecting from localhost... done. 

代码

def pserve(): 
    print '### I am starting demo ###' 
    #with settings(warn_only=True): 
    sudo('sudo service app start-demo') 
    #sudo('service app start-demo') 

sudo任一命令将失败。


/etc/sudoers

# /etc/sudoers 
# 
# This file MUST be edited with the 'visudo' command as root. 
# 
# See the man page for details on how to write a sudoers file. 
# 

Defaults env_reset 

# Host alias specification 

# User alias specification 

# Cmnd alias specification 

# User privilege specification 
root ALL=(ALL) ALL 

# Allow members of group sudo to execute any command after they have 
# provided their password 
# (Note that later entries override this, so you might need to move 
# it further down) 
%sudo ALL=(ALL) ALL 
# 
#includedir /etc/sudoers.d 

# Members of the admin group may gain root privileges 
%admin ALL=(ALL) NOPASSWD:ALL 
+0

您的'sudo'配置是否要求您在终端输入密码? – sarnold 2012-07-05 23:21:45

+0

你把命令放在引号中了吗?它应该是'sudo(“service app start-demo”)'。 – mayhewr 2012-07-06 00:02:24

+0

@sarnold它没有。当我在终端上做'sudo'时,它不会问。我跑作为晶圆厂,它也没有问。 – user423455 2012-07-06 01:48:43

回答

3

这prolly与此提及的faq,而且如果该命令不返回0(UNIX标准都好),它会快速失败的,除非你告诉它只是警告。

+0

Thansk!这是一个非常好的发现:)现在..还有一件事... fab不返回。它只是在那里等着。这是为什么? – user423455 2012-07-06 18:10:11

+0

最有可能是由于一些nohup或背景的东西,也[在FAQ中提到](http://docs.fabfile.org/en/1.4.2/faq.html#why-can-ti-run-programs-in -the-背景与 - 它-使织物恒) – Morgan 2012-07-09 15:18:58