rstudio / plumber

Turn your R code into a web API.
https://www.rplumber.io
Other
1.39k stars 256 forks source link

Issue with `do_deploy_api` #160

Closed joelgombin closed 7 years ago

joelgombin commented 7 years ago

I'm using do_deploy_api to deploy an API on a DO droplet. I get this output:

● plumber-cmarue.service - Plumber API
   Loaded: loaded (/etc/systemd/system/plumber-cmarue.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2017-08-22 07:39:05 UTC; 4s ago
 Main PID: 6353 (code=exited, status=1/FAILURE)

Aug 22 07:39:05 LoudestFluke Rscript[6353]: filter(): dplyr, stats
Aug 22 07:39:05 LoudestFluke Rscript[6353]: lag():    dplyr, stats
Aug 22 07:39:05 LoudestFluke Rscript[6353]: Cannot open data source ./PLU/PLU_PSMV_PROTCOM.shp
Aug 22 07:39:05 LoudestFluke Rscript[6353]: Error in CPL_read_ogr(dsn, layer, as.character(options), quiet, type,  :
Aug 22 07:39:05 LoudestFluke Rscript[6353]:   Open failed.
Aug 22 07:39:05 LoudestFluke Rscript[6353]: Calls: <Anonymous> ... <Anonymous> -> as.data.frame -> st_read -> CPL_read_ogr -> .Call
Aug 22 07:39:05 LoudestFluke Rscript[6353]: Execution halted
Aug 22 07:39:05 LoudestFluke systemd[1]: plumber-cmarue.service: Main process exited, code=exited, status=1/FAILURE
Aug 22 07:39:05 LoudestFluke systemd[1]: plumber-cmarue.service: Unit entered failed state.
Aug 22 07:39:05 LoudestFluke systemd[1]: plumber-cmarue.service: Failed with result 'exit-code'.
Erreur : ssh failed
ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/tmp/Rtmpa2gRuu/hosts root@104.131.155.178 'systemctl status plumber-cmarue'

But my API works locally, and if I ssh to my droplet and execute the plumber.R script, everything works fine. Any idea of what might be going wrong? Unfortunately the error message ("Open failed") here is not very informative.

joelgombin commented 7 years ago

In that case the plumber.R script would be executed from /var/plumber/cmarue (where it lives), right?

joelgombin commented 7 years ago

Ok I changed the path to the datafile to an absolute path and it works. I'll leave the issue open, because IMHO the R process should be launched from where the plumber.R file is. Using relative path really helps the development process (and is, I think, a good practice).

trestletech commented 7 years ago

Hi. So you're saying that the Cannot open data source ./PLU/PLU_PSMV_PROTCOM.shp path is something in your code and that when you changed it to an absolute path it worked?

Yeah, I would have expected a relative path to work, too. If you can confirm that that's the behavior you're seeing I'll take a look to see why the working directory isn't set properly.

joelgombin commented 7 years ago

Yes, I can confirm this.

trestletech commented 7 years ago

Great. If you install from sections and then redeploy the API, relative paths should now work.

trestletech commented 7 years ago

*install from devtools

joelgombin commented 7 years ago

It does indeed work. Thanks for the quick fix!