简体   繁体   中英

Rscript Not Starting httpuv Server

I am attempting to start a server using startServer() from the httpuv package through Rscript on Ubuntu 20.04. The server will bind to the port if I run create_server.R from RStudio or if I run from the command line R interface, but when I try:

Rscript create_server.R > outfile.Rout

it appears as if the file is executed but the port is not bound and the server is not created.

In the R interface, however, the following will run and bind the port:

source('create_server.R')

Does anyone know why running the script using Rscript isn't working or how to launch a persistent httpuv server from the terminal?

The contents of the .Rout file say it was started:

<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

Thanks.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM