Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何检查Shiny应用程序是否在特定ip和地址上运行?_R_Shiny - Fatal编程技术网

R 如何检查Shiny应用程序是否在特定ip和地址上运行?

R 如何检查Shiny应用程序是否在特定ip和地址上运行?,r,shiny,R,Shiny,我有一个闪亮的应用程序,在特定的ip地址和端口上运行 闪亮的\u开始\u脚本。R runApp(主机=myhost,端口=myport) 我想要另一个R脚本,它经常检查闪亮的应用程序是否处于活动状态。 通过这种方式,如果由于某种原因终止,脚本可以在runApp命令上方运行 我如何才能做到这一点?我正在使用非常类似的脚本,通过windows任务调度器的强大功能,使我闪亮的应用程序始终工作 这是您可以运行的脚本 library(httr) library(shiny) url <- &quo

我有一个闪亮的应用程序,在特定的ip地址和端口上运行

闪亮的\u开始\u脚本。R

runApp(主机=myhost,端口=myport)

我想要另一个R脚本,它经常检查闪亮的应用程序是否处于活动状态。
通过这种方式,如果由于某种原因终止,脚本可以在
runApp
命令上方运行


我如何才能做到这一点?

我正在使用非常类似的脚本,通过windows任务调度器的强大功能,使我闪亮的应用程序始终工作

这是您可以运行的脚本

library(httr)
library(shiny)

url <- "http://....." # your url or ip adress

out <- tryCatch(GET(url), error = function(e) e) # To find if your url working or not
logic  <- any(class(out) == "error") # returns TRUE/FALSE due to the existance of an error

   # The codes below stands for rerunning the main script if there exists an error.

if(logic) {

Sys.sleep(2)

wdir <- "your_working_directory"
setwd(wdir)

require(shiny)

x <- system("ipconfig", intern=TRUE)
z <- x[grep("IPv4", x)]
ip <- gsub(".*? ([[:digit:]])", "\\1", z)

source("./global.R")

runApp(wdir , launch.browser=FALSE, port = myport , host = ip)


}
库(httr)
图书馆(闪亮)
如果有
isRunning()
,则返回布尔值TRUE或FALSE(如果当前正在运行闪亮的应用程序)。