Once you’ve deployed your first application with buoyant, you’ll want to know how to manage it, update it, and use more advanced features. This guide covers everything from updating your deployed applications to running multiple apps on a single server, configuring HTTPS, and understanding how buoyant works under the hood.
This guide assumes you’ve already:
If you haven’t done these yet, start with the Getting Started guide first.
In this guide, you’ll learn how to:
Make changes locally, then redeploy:
do_deploy_server(
droplet = droplet,
path = "api",
local_path = "my-first-api",
port = 8000,
overwrite = TRUE # Replace existing deployment
)# Deploy a second application on the same server
do_deploy_server(
droplet = droplet,
path = "v2",
local_path = "my-second-api",
port = 8001 # Different port!
)
# Access at:
# http://<ip>/api (first app)
# http://<ip>/v2 (second app)# Stop and remove
do_remove_server(droplet, path = "api", delete = TRUE)When you’re completely done:
library(analogsea)
droplet_delete(droplet)Warning: This permanently deletes your server and all data!
You don’t need to create a new droplet every time. You can reference existing droplets:
# Get a reference to an existing droplet by ID
droplet <- droplet(id = 12345678)
# Or by name
library(purrr)
droplet <- droplets() %>%
keep(~ .x$name == "my-server") %>%
pluck(1)
# Deploy to it
do_deploy_server(droplet, "newapp", "path/to/app", port = 8002)You can customize the droplet specifications:
# Provision with specific size, region, and name
droplet <- do_provision(
size = "s-1vcpu-1gb", # 1 CPU, 1GB RAM
region = "sfo3", # San Francisco data center
name = "my-production-api" # Custom name
)Common droplet sizes: - s-1vcpu-512mb - $5/month (basic) - s-1vcpu-1gb - $10/month
See DigitalOcean pricing for current rates.
By default, applications are accessible at http://ip/path. You can forward the root path to an application:
# Make an app accessible at the root
do_forward(droplet, "myapp")
# Now accessible at: http://ip/ instead of http://ip/myapp
# Remove forwarding
do_remove_forward(droplet)If your application needs system libraries or R packages:
# Install system packages
droplet_ssh(droplet, "sudo apt-get install -y libgdal-dev")
# Install R packages on the server
do_install_server_deps(droplet, packages = c("sf", "terra"))SSH into your droplet to check logs:
droplet_ssh(droplet, "journalctl -u server-api -f")Or use analogsea’s convenience functions:
# Check if service is running
droplet_ssh(droplet, "systemctl status server-api")# View recent logs
droplet_ssh(droplet, "journalctl -u server-myapp -n 50")
# Follow logs in real-time
droplet_ssh(droplet, "journalctl -u server-myapp -f")# Check memory and CPU usage
droplet_ssh(droplet, "htop")
# Check disk usage
droplet_ssh(droplet, "df -h")If you have a domain name:
# Point your domain to the droplet IP
ip <- do_ip(droplet)
print(ip)
# After DNS is configured (wait for propagation):
do_configure_https(
droplet = droplet,
domain = "api.yourdomain.com",
email = "you@example.com",
terms_of_service = TRUE # Agree to Let's Encrypt TOS
)Now your API is available at https://api.yourdomain.com/api
Understanding how buoyant works under the hood can help with troubleshooting:
do_provision())/var/server-apps/)do_deploy_server())Uploads application files to /var/server-apps/<path>/
Installs the engine package if not present
Creates a systemd service file at /etc/systemd/system/server-<path>.service
The service runs:
Rscript -e "
engine <- yaml::read_yaml('_server.yml')$engine
launch_server <- get('launch_server', envir = asNamespace(engine))
launch_server('_server.yml', host = '127.0.0.1', port = <port>)
"Creates nginx configuration at /etc/nginx/sites-available/server-<path>
Enables and starts the service
do_configure_https())_server.yml)droplet_delete())If you’re familiar with plumberDeploy, here’s how buoyant differs:
| Feature | buoyant | plumberDeploy |
|---|---|---|
| Framework Support | Any _server.yml engine |
plumber only |
| Configuration | _server.yml standard |
plumber.R files |
| Deployment Target | DigitalOcean | DigitalOcean, AWS, Azure |
| HTTPS Support | Yes (Let’s Encrypt) | Yes (Let’s Encrypt) |
| Multiple Apps | Yes | Yes |
buoyant is more focused but framework-agnostic, while plumberDeploy supports multiple cloud providers but is specific to plumber.