Description Usage Arguments Details Value Note Examples
View source: R/digital-ocean.R
Create (if required), install the necessary prerequisites, and
deploy a sample plumber application on a DigitalOcean virtual machine.
You may sign up for a Digital Ocean account
here.
You should configure an account ssh key with analogsea::key_create()
prior to using this method.
This command is idempotent, so feel free to run it on a single server multiple times.
1 2 3 4 5 | do_provision(droplet, unstable = FALSE, example = TRUE, ...)
do_install_plumber(droplet, unstable, ...)
do_ip(droplet, path)
|
droplet |
The DigitalOcean droplet that you want to provision
(see |
unstable |
If |
example |
If |
... |
Arguments passed into the |
path |
path to attach to the IP address before browsing. Should likely
start with a |
Provisions a Ubuntu 20.04-x64 droplet with the following customizations:
A recent version of R installed
plumber installed globally in the system library
An example plumber API deployed at /var/plumber
A systemd definition for the above plumber API which will ensure that the plumber
API is started on machine boot and respawned if the R process ever crashes. On the
server you can use commands like systemctl restart plumber
to manage your API, or
journalctl -u plumber
to see the logs associated with your plumber process.
The 'nginx“ web server installed to route web traffic from port 80 (HTTP) to your plumber process.
ufw
installed as a firewall to restrict access on the server. By default it only
allows incoming traffic on port 22 (SSH) and port 80 (HTTP).
A 4GB swap file is created to ensure that machines with little RAM (the default) are able to get through the necessary R package compilations.
The DigitalOcean droplet
The URL to be browsed
Please see https://github.com/sckott/analogsea/issues/205 in case
of an error by default do_provision
and an error of
"Error: Size is not available in this region."
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ## Not run:
auth = try(analogsea::do_oauth())
if (!inherits(auth, "try-error") &&
inherits(auth, "request")) {
analogsea::droplets()
droplet = do_provision(region = "sfo3", example = FALSE)
analogsea::droplets()
analogsea::install_r_package(droplet, c("readr", "remotes"))
do_deploy_api(droplet, "hello",
system.file("plumber", "10-welcome", package = "plumber"),
port=8000, forward=TRUE)
if (interactive()) {
utils::browseURL(do_ip(droplet, "/hello"))
}
analogsea::droplet_delete(droplet)
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.