【问题标题】:Rscript Not Starting httpuv ServerRscript没有启动httpuv服务器
【发布时间】:2021-02-22 18:26:52
【问题描述】:

我正在尝试通过 Ubuntu 20.04 上的 Rscript 使用 httpuv 包中的 startServer() 启动服务器。如果我从 RStudio 运行 create_server.R 或从命令行 R 界面运行,服务器将绑定到端口,但是当我尝试时:

Rscript create_server.R > outfile.Rout

看起来好像文件已执行但端口未绑定且服务器未创建。

然而,在 R 界面中,以下将运行并绑定端口:

source('create_server.R')

有谁知道为什么使用 Rscript 运行脚本不起作用或如何从终端启动持久 httpuv 服务器?

.Rout 文件的内容表明它已启动:

<WebServer>
  Inherits from: <Server>
  Public:
    getHost: function () 
    getPort: function () 
    getStaticPathOptions: function () 
    getStaticPaths: function () 
    initialize: function (host, port, app, quiet = FALSE) 
    isRunning: function () 
    removeStaticPath: function (path) 
    setStaticPath: function (..., .list = NULL) 
    setStaticPathOption: function (..., .list = NULL) 
    stop: function () 
  Private:
    appWrapper: AppWrapper, R6
    handle: 140156258489016
    host: 127.0.0.1
    port: 5001
    running: TRUE

谢谢。

【问题讨论】:

    标签: r ubuntu rscript httpuv


    【解决方案1】:

    如果您希望使用 Rscript 运行,您似乎必须使用 runServer() 而不是 startServer()

    【讨论】:

      猜你喜欢
      • 2015-02-13
      • 2014-02-09
      • 2021-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-15
      • 2014-11-03
      • 1970-01-01
      相关资源
      最近更新 更多