Last active
September 22, 2017 16:10
-
-
Save sellorm/310efb56a63e3321b70cd094aad8b09e to your computer and use it in GitHub Desktop.
A quick script, written in R, to launch API's written using the plumber package for R. Don't forget to 'chmod +x plumberStart.R'. Usage should be 'plumberStart.R /path/to/plumber/file.R <port>', if port is omitted, the script will use 8080 as a default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env Rscript | |
args <- commandArgs(trailingOnly = TRUE) | |
if (is.na(args[1])) { | |
cat('Missing file name\n') | |
q('no') | |
} else { | |
file <- args[1] | |
} | |
if (is.na(args[2])) { | |
cat('No port specified - defaulting to 8080\n') | |
port <- 8080 | |
} else { | |
port <- as.numeric(args[2]) | |
} | |
library(plumber) | |
r <- plumb(file) | |
r$run(port=port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment