subprocess.Popen在启动Rserve

时间:2015-06-06 14:38:36

标签: python-2.7 subprocess popen rserve pyrserve

本地系统: OSX 10.10.3约塞米蒂 Python 2.7

远程服务器: NAME ="亚马逊Linux AMI" VERSION =" 2014.09"

我尝试使用Python启动(重启)服务器上的Rserve进程。我可以直接启动它作为ec2用户($ R CMD Rserve - vanilla)或使用SystemV脚本($ service Rserve restart)...但是Python脚本仍然在等待启动的Rserve进程完成。由于它是一个守护进程,它没有完成并且脚本挂起。

我已经尝试了subprocess.call和子进程Popen。

log.error('Attempting to restart Rserve environment...')
PEM  = "/Users/xxx/ra.pem"
USER = "ec2-user"
PORT = '22'
SERVER = str(callobj.rhandler_host) # ends up confirmed correct IP
command = ['/sbin/service', 'Rserve', 'restart'] # Starts Rserve and hangs
# command = ['R', 'CMD', 'Rserve', '--vanilla'] # Starts Rserve and hangs
# command = ['ls'] # lists and finishes

ssh = ['ssh', '-i', PEM, '-p', PORT, USER + '@' + SERVER]
run = ssh + command

proc = subprocess.Popen(run, shell=False, 
#                         stdout=subprocess.PIPE) # Tried this, no change 
                          stdin=None, stdout=None, stderr=None, close_fds=True)

输出:

2015-06-06 16:51:51,362 - MRATrefactor - ERROR - [R] environment does not appear to be running on server '54.xxx.xxx.x2'. Connection denied, server not reachable or not accepting connections
2015-06-06 16:51:51,363 - MRATrefactor - ERROR - rserveHandler.connect: ; *args: None; **kwargs: None; RserveNotRunning: [R] environment does not appear to be running on server '54.xxx.xxx.x2'. Connection denied, server not reachable or not accepting connections. Rserve may not be running.
2015-06-06 16:51:51,363 - MRATrefactor - ERROR - Attempting to restart Rserve environment...
    PID: 8205
    Cannot match 8205 to running processes.
    Grepping for process [expecting PID: 8205]...

    grep count: 0
    0
    Stopping Rserve:  [FAILED]
    Starting Rserve: 
    R version 3.1.1 (2014-07-10) -- "Sock it to Me"
    Copyright (C) 2014 The R Foundation for Statistical Computing
    Platform: x86_64-redhat-linux-gnu (64-bit)

    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under certain conditions.
    Type 'license()' or 'licence()' for distribution details.

    Natural language support but running in an English locale

    R is a collaborative project with many contributors.
    Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications.

    Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help.
    Type 'q()' to quit R.

    Rserv started in daemon mode.
    ec2-user 8385 1 0 14:51 ? 00:00:00 /usr/lib64/R/bin/Rserve --vanilla
    PID: 8385
    Starting Rserve:  [  OK  ]

(and script hangs here...apparently (maybe) waiting...?)

0 个答案:

没有答案