0

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.

Andrew Hardiman
  • 929
  • 1
  • 15
  • 30
Tim
  • 13
  • 4

1 Answers1

0

It appears you have to use runServer() rather than startServer() if you are hoping to run using Rscript.

Tim
  • 13
  • 4