为什么 运行 shiny 从 cmd 行启动时会在 windows 上启动两个 Rscript 进程?
Why does running shiny start two Rscript processes on windows when launching from cmd line?
当我从 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
并查看该应用程序。但是,如果我通过以下方式查看我的 运行ning 进程: tasklist /FI "imagename eq rscript*"
我看到 two Rscript.exe
进程:
然而,我确定的是,我总是可以杀死两者中较小的一个(例如,taskkill /pid 9360 /f
),但该应用程序仍能正常运行?注意:我尝试通过 START \b ...
在后台启动命令,但结果是一样的。
这是 R 脚本命令行实用程序(Rscript.exe
、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'
您可以试用其他工具,看看它们的行为如何。
更多信息,查看源代码
- https://github.com/wch/r-source/blob/trunk/src/gnuwin32/front-ends
- https://github.com/wch/r-source/blob/trunk/src/unix/Rscript.c
这个问题也有一些很好的信息
- R.exe, Rcmd.exe, Rscript.exe and Rterm.exe: what's the difference?
当我从 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
并查看该应用程序。但是,如果我通过以下方式查看我的 运行ning 进程: tasklist /FI "imagename eq rscript*"
我看到 two Rscript.exe
进程:
然而,我确定的是,我总是可以杀死两者中较小的一个(例如,taskkill /pid 9360 /f
),但该应用程序仍能正常运行?注意:我尝试通过 START \b ...
在后台启动命令,但结果是一样的。
这是 R 脚本命令行实用程序(Rscript.exe
、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'
您可以试用其他工具,看看它们的行为如何。
更多信息,查看源代码
- https://github.com/wch/r-source/blob/trunk/src/gnuwin32/front-ends
- https://github.com/wch/r-source/blob/trunk/src/unix/Rscript.c
这个问题也有一些很好的信息
- R.exe, Rcmd.exe, Rscript.exe and Rterm.exe: what's the difference?