I have developed a REST API using plumber. When I start the REST API from RStudio using the following command:
plumber::plumb("/PATH/TO/rest-api/scrnaseq-server.R")$run(port = 9000, host = "0.0.0.0")
... then I am able to view the Swagger UI at:
http://:9000/swagger/
However when I deploy the REST API as a service, I am unable to view the Swagger UI at the same URL.
My /etc/systemd/system/plumber-api.service
looks like the following:
[Unit]
Description=Plumber API
# After=postgresql
# (or mariadb, mysql, etc if you use a DB with Plumber, otherwise leave this commented)
[Service]
ExecStart=/usr/bin/Rscript -e "api <- plumber::plumb('/PATH/TO/rest-api/scrnaseq-server.R'); api$run(port=9000, host='0.0.0.0')"
Restart=on-abnormal
WorkingDirectory=/PATH/TO/rest-api/
[Install]
WantedBy=multi-user.target