2012-07-05 21 views
5

Tôi có lệnh service app start-demo yêu cầu tôi nhập sudo service app start-demo trong dòng lệnh.thực hiện như sudo trong vải

tôi đã sử dụng sudo(service app start-demo)sudo(sudo service app start-demo) nhưng tôi vẫn nhận được

Cảnh báo: sudo() gặp phải một lỗi (trả lại mã 1) trong khi thực hiện 'ứng dụng dịch vụ sudo bắt đầu-demo'

Tôi không có vấn đề thực hiện mà như một dòng lệnh trong một thiết bị đầu cuối.

Tôi không chắc chắn nếu SADeprecationWarning: được tính là không thể vải?

Cảm ơn.


[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') 

hoặc lệnh sudo sẽ thất bại.


/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

Cấu hình 'sudo' của bạn có yêu cầu bạn nhập mật khẩu tại thiết bị đầu cuối không? – sarnold

+0

Bạn đã đặt lệnh trong dấu ngoặc kép chưa? Nó phải là 'sudo (" dịch vụ ứng dụng bắt đầu-demo ")'. – mayhewr

+0

@sarnold Nó không. Khi tôi làm 'sudo' trên thiết bị đầu cuối, nó sẽ không hỏi. Tôi chạy như fab nó đã không yêu cầu một trong hai. – user423455

Trả lời

3

này được prolly liên quan đến đề cập này trong faq, mà còn nếu lệnh không trả lại 0 (tiêu chuẩn unix cho tất cả tốt) nó sẽ thất bại nhanh trừ bạn nói với nó để cảnh báo mà thôi.

+0

Thansk! Đó là một phát hiện rất tốt :) Bây giờ .. một điều nữa ... fab không trở lại. Nó chỉ đợi ở đó. Tại sao vậy? – user423455

+0

Rất có thể là do một số công cụ nohup hoặc backgrounding, cũng [được đề cập trong FAQ] (http://docs.fabfile.org/en/1.4.2/faq.html#why-can-ti-run-programs-in -the-background-with-it-make-fabric-hang) – Morgan

Các vấn đề liên quan