从 cmd 行启动时,为什么在 Windows 上运行 Shiny 会启动两个 Rscript 进程?

Jas*_*lns 5 cmd r shiny shiny-server

当我启动R运行一个脚本shiny从应用程序cmd行,它似乎推出2个的实例Rscript.exe?我总是可以杀死两者中较小的一个并且应用程序继续运行?有人可以详细说明幕后实际发生的事情,或者告诉我我做错了什么导致双重流程?


超级简单.R

require(shiny)

app <- shinyApp(
  ui = bootstrapPage(
    numericInput('n', 'Number of obs', 100),
    plotOutput('plot')
  ),
  server = function(input, output) {
    output$plot <- renderPlot({ hist(runif(input$n)) })
  }
)

runApp(app, launch.browser = FALSE, port = 1234, host = "10.123.4.56")
Run Code Online (Sandbox Code Playgroud)

现在,如果我通过以下cmd线路启动它:

START Rscript --vanilla C:\Users\Jason\Projects\super_simple.R
Run Code Online (Sandbox Code Playgroud)

此时,我可以将浏览器指向http://10.123.4.56:1234并查看该应用程序。但是,如果我通过以下方式tasklist /FI "imagename eq rscript*"查看正在运行的进程:我看到两个 Rscript.exe进程:

流程

然而,我确定的是,我总是可以杀死两者中较小的一个(例如taskkill /pid 9360 /f),而该应用程序仍然可以完整运行?注意:我尝试通过在后台启动命令,START \b ...但结果是一样的。

gre*_*g L 4

Rscript.exe这是 R 脚本命令行实用程序( 、R.exe、 )的一般情况Rcmd.exe,而不是 Shiny 特有的。所有这些实际上都Rterm.exe在下面调用以在单独的进程中运行实际的程序。

尝试Rscript.exe一下 --verbose,你就会明白我的意思:

> Rscript --verbose script.R
running
  'C:\PROGRA~1\R\R-34~1.0\bin\x64\Rterm.exe --slave --no-restore --file=script.R'
Run Code Online (Sandbox Code Playgroud)

您可以尝试其他工具并查看它们的行为方式。

欲了解更多信息,请查看源代码

这个问题也有一些很好的信息