2016-10-11 120 views
2

我目前正试图在Windows计算机上使用计划任务部署闪亮的应用。这个想法是,脚本每天早上运行并汇总来自多个位置的数据,然后将其放入一些Rdata.table对象中,以用于shiny应用程序。使用命令行部署闪亮的应用时出错

我正在使用taskscheduleR来安排任务。它最初将工作目录设置为C:/Windows/system32,因此我将其修复为指向我的应用程序所在的目录(C:/rprojects/myappname)。脚本运行良好,直到我尝试部署文件。

​​

当我从taskscheduleR检查日志,我有以下行

Preparing to deploy application...DONE 
Uploading bundle for application: 999999...Error in contrib.url(getOption("repos"), type) : 
    trying to use CRAN without setting a mirror 
Calls: deployApp ... withCallingHandlers -> <Anonymous> -> available.packages -> contrib.url 
Execution halted 

我搜索过的错误信息,以及所有我能找到使用install.packages()当涉及到设置回购我不要在我的脚本中使用。我期望它涉及如何deployApp试图找到URL但是我可以理解我可能需要(或能够)声明存储库的位置。

更新(2016年10月11日): 我已经激活了几个选项rsconnect就要上部署的更多详细信息。不幸的是,它无助于提供更清晰的信息。

options(rsconnect.http.trace = TRUE) 
options(rsconnect.http.trace.json = TRUE) 
options(rsconnect.http.verbose = TRUE) 

下面是从log

GET /v1/applications/?filter=account_id:999999&filter=name:myappname&count=100&offset=0 1500ms 
* Hostname was NOT found in DNS cache 
* Trying 54.225.182.222... 
* Trying 174.129.219.111... 
* Connected to api.shinyapps.io (54.225.182.222) port 443 (#0) 
    * successfully set certificate verify locations: 
    * CAfile: C:/RLibrary/rsconnect/cert/cacert.pem 
    CApath: none 
    * SSL connection using TLSv1.0/ECDHE-RSA-AES128-SHA 
    * Server certificate: 
    * subject: OU=Domain Control Validated; CN=*.shinyapps.io 
    *  start date: 2016-07-18 14:17:38 GMT 
    *  expire date: 2017-09-09 23:05:10 GMT 
    *  subjectAltName: api.shinyapps.io matched 
    *  issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certs.godaddy.com/repository/; CN=Go Daddy Secure Certificate Authority - G2 
    *  SSL certificate verify ok. 
    > GET /v1/applications/?filter=account_id:999999&filter=name:myappname&count=100&offset=0 HTTP/1.1 
    User-Agent: rsconnect/0.4.3 
    Host: api.shinyapps.io 
    Accept: */* 
    Date: Tue, 11 Oct 2016 01:26:02 GMT 
    X-Auth-Token: xxxxxx 
    X-Auth-Signature: xxxxxx; version=1 
    X-Content-Checksum: xxxxxx 

    < HTTP/1.1 200 OK 
    < Content-Type: application/json; charset=UTF-8 
    < Date: Tue, 11 Oct 2016 01:23:36 GMT 
    < Etag: "xxxxxx" 
    < Server: nginx/1.4.2 
    < Content-Length: 3212 
    < Connection: keep-alive 
    < 
    * Connection #0 to host api.shinyapps.io left intact 
    Error in contrib.url(getOption("repos"), type) : 
    trying to use CRAN without setting a mirror 
    Calls: deployApp ... withCallingHandlers -> <Anonymous> -> available.packages -> contrib.url 
    Execution halted 
+1

看看这是否有用http://stackoverflow.com/questions/17705133/package-error-when-running-r-code-on-command-line当你在代码中有'library(something)'时, 'deployApp'函数将需要在服务器上安装软件包,如果它们没有安装,那就是'install.packages'进来的地方。 –

+0

据我可以从'rsconnect'的文档中看出来,它会查找'库“,这是闪亮的应用程序所必需的,并将其安装在'shinyapps.io'上。我可能会错过一些东西,但我会认为服务器负责设置回购。 – Dan

+0

我更新了'.rprofile'文件以包含默认的'CRAN'镜像,并且它部署正常。 – Dan

回答

3

输出设置

options(repos = c(CRAN = "https://cran.rstudio.com/")) 
在你的脚本,你想用的TaskScheduler 推出如果您RSCRIPT推出的R顶

某处,CRAN库不会被设置,这是不同的,如果你在RStudio编辑器中运行你的代码。

+0

我将该行添加到'deploy.R'脚本中,该脚本适用于我的应用程序,现在它运行良好。 –

+0

谢谢!应该是被接受的答案。 –

相关问题