Closed incredibeau closed 4 years ago
From tutorial provided, endpoint should be http://[[IPADDRESS]]/date
This works on my end.
Local file ./api/plumber.R
#* @get /
function() {
Sys.Date()
}
Running
id <- plumberDeploy::do_provision(example = FALSE)
plumberDeploy::do_deploy_api(id, "date", "./api/", 8000, docs = TRUE)
Navigating to : [[IPADDRESS]]/date
Thank you for the quick response. The problem seemed to be that I needed the docs = TRUE
parameter in do_deploy_api()
. I am able to successfully run:
id <- plumberDeploy::do_provision(example = FALSE)
plumberDeploy::do_deploy_api(id, "date", "./api/", 8000, docs = TRUE)
And can navigate to : [[IPADDRESS]]/date
However, a new problem has emerged. When I update the api (rerun plumberDeploy::do_deploy_api(id, "date", "./api/", 8000, docs = TRUE)
), I get an SSH error:
Error: ssh failed
mv /tmp/IWASQQZTKA/march_api/ /var/plumber/test
My SSH public key is registered using analogsea::keys()
and I also have a DO_PAT
environmental variable. SSH seems to work on the initial do_provision()
and do_deploy_api()
but not on subsequent updates. Any idea what could be going wrong.
Could be that test/ already exists, so we may need to do a cp or an rm -rf https://unix.stackexchange.com/questions/9899/how-to-overwrite-target-files-with-mv before mv on line https://github.com/meztez/plumberDeploy/blob/master/R/digital-ocean.R#L321 Best, John
On Tue, Sep 29, 2020 at 3:01 PM Beau Walker notifications@github.com wrote:
Thank you for the quick response. The problem seemed to be that I needed the docs = TRUE parameter in do_deploy_api(). I am able to successfully run:
id <- plumberDeploy::do_provision(example = FALSE) plumberDeploy::do_deploy_api(id, "date", "./api/", 8000, docs = TRUE)
And can navigate to : [[IPADDRESS]]/date
However, a new problem has emerged. When I got to update the api (rerun plumberDeploy::do_deploy_api(id, "date", "./api/", 8000, docs = TRUE) ), I get an SSH error:
Error: ssh failed mv /tmp/IWASQQZTKA/march_api/ /var/plumber/test
My SSH public key is registered using analogsea::keys() and I also have a DO_PAT environmental variable. SSH seems to work on the initial do_provision() and do_deploy_api() but not on subsequent updates. Any idea what could be going wrong.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/meztez/plumberDeploy/issues/14#issuecomment-700918205, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIGPLTVJRIDMQBRHJQHTRDSIIVGXANCNFSM4R5ERVCQ .
@muschellij2 Thank you. I've also tried removing the API entirely with do_remove_api(id, 'test')
and re-uploading with do_deploy_api()
and get the same error.
Also, just got a notification that DigitalOcean is having some outages in some resource groups that may be affecting this. Also getting this error:
error in ssh::ssh_info(session = session) :
ssh session has been disconnected
library(plumberDeploy)
library(analogsea)
#>
#> Attaching package: 'analogsea'
#> The following object is masked from 'package:graphics':
#>
#> image
library(pagedown)
library(httr)
library(magick)
#> Linking to ImageMagick 6.9.9.39
#> Enabled features: cairo, fontconfig, freetype, lcms, pango, rsvg, webp
#> Disabled features: fftw, ghostscript, x11
#>
#> Attaching package: 'magick'
#> The following object is masked from 'package:analogsea':
#>
#> image_convert
d = droplets()
if (length(d) == 0) {
droplet = do_provision(example = FALSE)
} else {
droplet = d[[1]]
}
ip = analogsea:::droplet_ip(droplet)
url = paste0("http://", ip)
path = "date"
applet_url = paste0("http://", ip, "/", path)
do_remove_api(droplet, path = path, delete = TRUE)
#> stopping service: plumber-date
#> disabling service: plumber-date
#> removing service: plumber-date
#> removing config: plumber-date
#> reloading nginx: plumber-date
#> reloading plumber folder: plumber-date
#> <droplet>ConfidentConspiracy (210178483)
#> IP: 167.172.213.184
#> Status: active
#> Region: San Francisco 2
#> Image: 20.04 (LTS) x64
#> Size: s-1vcpu-1gb
#> Volumes:
api = '#* @get /
function() {
Sys.Date()
}'
tfile = tempfile()
dir.create(tfile)
outfile = file.path(tfile, "plumber.R")
writeLines(api, outfile)
file.exists(outfile)
#> [1] TRUE
readLines(outfile)
#> [1] "#* @get /" "function() {" " Sys.Date()" "}"
output_image = tempfile(fileext = ".png")
do_remove_api(droplet, path = path, delete = TRUE)
#> stopping service: plumber-date
#> disabling service: plumber-date
#> removing service: plumber-date
#> removing config: plumber-date
#> reloading nginx: plumber-date
#> reloading plumber folder: plumber-date
#> <droplet>ConfidentConspiracy (210178483)
#> IP: 167.172.213.184
#> Status: active
#> Region: San Francisco 2
#> Image: 20.04 (LTS) x64
#> Size: s-1vcpu-1gb
#> Volumes:
Deploying
plumberDeploy::do_deploy_api(droplet, path, tfile, port = 8000, docs = TRUE,
forward = TRUE)
#> [100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d764ca0b2a/plumber.R[100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d764ca0b2a/plumber.R
#> /tmp/UCHSKBJIYK
#> [100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d735f1d7f0[100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d735f1d7f0
#> /etc/systemd/system/plumber-date.service
#> ● plumber-date.service - Plumber API
#> Loaded: loaded (/etc/systemd/system/plumber-date.service; enabled; vendor preset: enabled)
#> Active: active (running) since Thu 2020-10-01 16:55:36 UTC; 1s ago
#> Main PID: 52656 (R)
#> Tasks: 2 (limit: 1137)
#> Memory: 63.1M
#> CGroup: /system.slice/plumber-date.service
#> └─52656 /usr/lib/R/bin/exec/R --no-echo --no-restore -e pr~+~<-~+~plumber::pr('/var/plumber/date/plumber.R');~+~pr$setDocs(TRUE);~+~~+~pr$run(port=8000)
#>
#> Oct 01 16:55:36 ConfidentConspiracy systemd[1]: Started Plumber API.
#> Oct 01 16:55:36 ConfidentConspiracy Rscript[52656]: Running plumber API at http://127.0.0.1:8000
#> Oct 01 16:55:36 ConfidentConspiracy Rscript[52656]: Running swagger Docs at http://127.0.0.1:8000/__docs__/
#> [100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d71897e93b[100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d71897e93b
#> /etc/nginx/sites-available/plumber-apis/date.conf
#> [100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d71d512d1a[100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d71d512d1a
#> /etc/nginx/sites-available/plumber-apis/_forward.conf
pagedown::chrome_print(input = applet_url, output = output_image,
format = "png")
image_read(output_image)
res = httr::GET(applet_url)
httr::status_code(res)
#> [1] 200
print(res)
#> Response [http://167.172.213.184/date/]
#> Date: 2020-10-01 16:55
#> Status: 200
#> Content-Type: application/json
#> Size: 14 B
This should fail now because deleted
do_remove_api(droplet, path = path, delete = TRUE)
#> stopping service: plumber-date
#> disabling service: plumber-date
#> removing service: plumber-date
#> removing config: plumber-date
#> reloading nginx: plumber-date
#> reloading plumber folder: plumber-date
#> <droplet>ConfidentConspiracy (210178483)
#> IP: 167.172.213.184
#> Status: active
#> Region: San Francisco 2
#> Image: 20.04 (LTS) x64
#> Size: s-1vcpu-1gb
#> Volumes:
res = httr::GET(applet_url)
httr::status_code(res)
#> [1] 404
print(res)
#> Response [http://167.172.213.184/date]
#> Date: 2020-10-01 16:55
#> Status: 404
#> Content-Type: text/html
#> Size: 162 B
#> <html>
#> <head><title>404 Not Found</title></head>
#> <body>
#> <center><h1>404 Not Found</h1></center>
#> <hr><center>nginx/1.18.0 (Ubuntu)</center>
#> </body>
#> </html>
Removing Docs=TRUE
plumberDeploy::do_deploy_api(droplet, path, tfile, port = 8000, docs = FALSE,
forward = TRUE)
#> [100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d764ca0b2a/plumber.R[100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d764ca0b2a/plumber.R
#> /tmp/RQFASCZMTS
#> [100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d77242de46[100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d77242de46
#> /etc/systemd/system/plumber-date.service
#> ● plumber-date.service - Plumber API
#> Loaded: loaded (/etc/systemd/system/plumber-date.service; enabled; vendor preset: enabled)
#> Active: active (running) since Thu 2020-10-01 16:55:50 UTC; 1s ago
#> Main PID: 52824 (R)
#> Tasks: 2 (limit: 1137)
#> Memory: 63.1M
#> CGroup: /system.slice/plumber-date.service
#> └─52824 /usr/lib/R/bin/exec/R --no-echo --no-restore -e pr~+~<-~+~plumber::pr('/var/plumber/date/plumber.R');~+~pr$setDocs(TRUE);~+~~+~pr$run(port=8000)
#>
#> Oct 01 16:55:50 ConfidentConspiracy systemd[1]: Started Plumber API.
#> Oct 01 16:55:51 ConfidentConspiracy Rscript[52824]: Running plumber API at http://127.0.0.1:8000
#> Oct 01 16:55:51 ConfidentConspiracy Rscript[52824]: Running swagger Docs at http://127.0.0.1:8000/__docs__/
#> [100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d740f0045[100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d740f0045
#> /etc/nginx/sites-available/plumber-apis/date.conf
#> [100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d774dab417[100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d774dab417
#> /etc/nginx/sites-available/plumber-apis/_forward.conf
pagedown::chrome_print(input = applet_url, output = output_image,
format = "png")
image_read(output_image)
res = httr::GET(applet_url)
httr::status_code(res)
#> [1] 200
print(res)
#> Response [http://167.172.213.184/date/]
#> Date: 2020-10-01 16:55
#> Status: 200
#> Content-Type: application/json
#> Size: 14 B
httr::content(res)
#> [[1]]
#> [1] "2020-10-01"
Removing forward
do_remove_api(droplet, path = path, delete = TRUE)
#> stopping service: plumber-date
#> disabling service: plumber-date
#> removing service: plumber-date
#> removing config: plumber-date
#> reloading nginx: plumber-date
#> reloading plumber folder: plumber-date
#> <droplet>ConfidentConspiracy (210178483)
#> IP: 167.172.213.184
#> Status: active
#> Region: San Francisco 2
#> Image: 20.04 (LTS) x64
#> Size: s-1vcpu-1gb
#> Volumes:
plumberDeploy::do_deploy_api(droplet, path, tfile, port = 8000, docs = FALSE,
forward = FALSE)
#> [100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d764ca0b2a/plumber.R[100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d764ca0b2a/plumber.R
#> /tmp/SEHZUJNLKX
#> [100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d7331ed10a[100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d7331ed10a
#> /etc/systemd/system/plumber-date.service
#> ● plumber-date.service - Plumber API
#> Loaded: loaded (/etc/systemd/system/plumber-date.service; enabled; vendor preset: enabled)
#> Active: active (running) since Thu 2020-10-01 16:56:05 UTC; 1s ago
#> Main PID: 52982 (R)
#> Tasks: 2 (limit: 1137)
#> Memory: 63.1M
#> CGroup: /system.slice/plumber-date.service
#> └─52982 /usr/lib/R/bin/exec/R --no-echo --no-restore -e pr~+~<-~+~plumber::pr('/var/plumber/date/plumber.R');~+~pr$setDocs(TRUE);~+~~+~pr$run(port=8000)
#>
#> Oct 01 16:56:05 ConfidentConspiracy systemd[1]: Started Plumber API.
#> Oct 01 16:56:05 ConfidentConspiracy Rscript[52982]: Running plumber API at http://127.0.0.1:8000
#> Oct 01 16:56:06 ConfidentConspiracy Rscript[52982]: Running swagger Docs at http://127.0.0.1:8000/__docs__/
#> [100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d72c2e01be[100%] /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpDmA9Mf/file27d72c2e01be
#> /etc/nginx/sites-available/plumber-apis/date.conf
pagedown::chrome_print(input = applet_url, output = output_image,
format = "png")
image_read(output_image)
res = httr::GET(applet_url)
httr::status_code(res)
#> [1] 200
print(res)
#> Response [http://167.172.213.184/date/]
#> Date: 2020-10-01 16:56
#> Status: 200
#> Content-Type: application/json
#> Size: 14 B
httr::content(res)
#> [[1]]
#> [1] "2020-10-01"
Created on 2020-10-01 by the reprex package (v0.3.0.9001)
@incredibeau is this resolved?
Help!
I've been following the instructions in this tutorial exactly (even uploading the provided plumber.R file): https://www.r-bloggers.com/2017/06/deploying-a-minimal-api-using-plumber-on-digitalocean/.
plumberDeploy::do_provision(unstable = T, example = TRUE)
works without any errors and will publish the example/hello/
api with no problems. So it's not an issue with SSH.When I create a new provision without the example:
plumberDeploy::do_deploy_api(id,"test", "path/to/plumber/folder", 8000)
I don't get any errors and get the following feedback that looks like a success message:
However, when I try to curl or navigate to the api:
[[IPADDRESS]]/test
or to any of the endpoints, I get a 404 error. Can someone help me troubleshoot what is going wrong?