【问题标题】:Why does running shiny start two Rscript processes on windows when launching from cmd line?从 cmd 行启动时,为什么运行闪亮会在 Windows 上启动两个 Rscript 进程?
【发布时间】:2018-05-19 14:57:17
【问题描述】:

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


super_simple.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")

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

START Rscript --vanilla C:\Users\Jason\Projects\super_simple.R

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

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

【问题讨论】:

  • 我猜一个实例运行你的脚本,runApp 只为应用程序本身创建第二个实例。

标签: r cmd shiny shiny-server


【解决方案1】:

这是 R 脚本命令行实用程序(Rscript.exeR.exeRcmd.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'

您可以尝试其他工具,看看它们的表现如何。

更多信息,请查看源代码

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-28
    • 1970-01-01
    • 1970-01-01
    • 2015-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多