在 Fabric 中作为 sudo 执行

2024-03-23

我有一个命令service app start-demo需要我输入sudo service app start-demo在命令行中。

I used sudo(service app start-demo) and sudo(sudo service app start-demo)但我仍然得到

警告:执行“sudo service app start-demo”时 sudo() 遇到错误(返回代码 1)

我在终端中将其作为命令行执行没有问题。

我不确定是否SADeprecationWarning:算作布料失败吗?

Thanks.


user@box:/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.

the code

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

either 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

这很可能与本文中提到的有关faq http://docs.fabfile.org/en/1.4.2/faq.html#init-scripts-don-t-work,而且如果命令不返回 0(unix 标准),它会快速失败,除非你告诉它只发出警告。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Fabric 中作为 sudo 执行 的相关文章

随机推荐