tech:
NOTE: The deployed API doesn't actually use docker as the instance was too small to support Docker. But the Ruby/Sinata/postgres/puma/caddy/etc. setup still applies.
Within popler_API on the server there is a puma.rb
file.
As you can see in the puma.rb
file, the API runs on port 8834. To see if puma is running, execute lsof -i :8834 -t
. If nothing is found, then it's not running. If it gives back any output, those are the PID's for the processes, and it is running.
To start puma run bundle exec puma -C puma.rb
To stop puma run kill $(lsof -i :8834 -t)
Puma is what runs the API locally on the server, but to serve the API to the world/public, we use the Caddy server.
To start Caddy run sudo caddy -port 443 -agree -email=myrmecocystus@gmail.com &
(and ctrl + ^c afterwards as it will just hang)
To stop Caddy run sudo pkill caddy
You can see that Caddy is running when you do a request, e.g.:
curl -v https://popler.space/heartbeat
> GET /heartbeat HTTP/2
> Host: popler.space
> User-Agent: curl/7.54.0
> Accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 200
< access-control-allow-methods: HEAD, GET
...
< server: Caddy <------- LOOK HERE
...
https://popler.space/
https://popler.space/heartbeat/
https://popler.space/summary/
https://popler.space/search?proj_metadata_key=3
https://popler.space/search?proj_metadata_key=3&genus=Strongylocentrotus
https://popler.space/search?proj_metadata_key=3&genus=Strongylocentrotus&species=franciscanus