Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from CodeforAustralia/fix/server-config
Fix server config
- Loading branch information
Showing
2 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# heritage-api - Start PostgREST API service for Heritage Near Me | ||
# This is an upstart config file for Linux; it goes in /etc/init | ||
# Read more: | ||
# * https://www.digitalocean.com/community/tutorials/the-upstart-event-system-what-it-is-and-how-to-use-it | ||
# * https://www.digitalocean.com/community/tutorials/how-to-configure-a-linux-service-to-start-automatically-after-a-crash-or-reboot-part-1-practical-examples | ||
|
||
# | ||
# Note: when installing this, run this as root before running the service: | ||
# | ||
# touch /var/log/heritage-api.log | ||
# chown postgres /var/log/heritage-api.log | ||
# mkdir -p /var/run/heritage | ||
# chown postgres /var/run/heritage | ||
|
||
|
||
description "Start Heritage Near Me API (PostgREST)" | ||
author "Peter W (@techieshark)" | ||
|
||
start on filesystem or runlevel [2345] | ||
stop on shutdown | ||
|
||
# Run as "postgres" user since that has correct access to database | ||
setuid postgres | ||
|
||
script | ||
|
||
echo $$ > /var/run/heritage-api.pid | ||
exec postgrest postgres://localhost:5432/hnm --port 3000 --schema hnm --anonymous postgres --pool 200 > /var/log/heritage-api.log | ||
|
||
end script | ||
|
||
|
||
pre-start script | ||
echo "[`date`] Heritage API Starting" >> /var/log/heritage-api.log | ||
end script | ||
|
||
|
||
pre-stop script | ||
rm /var/run/heritage-api.pid | ||
echo "[`date`] Heritage API Stopping" >> /var/log/heritage-api.log | ||
end script |