2016-10-11 114 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

謝謝!應該是被接受的答案。 –