pg-rest-api/doc/deployment-with-pm2.md

1.2 KiB

Deployment with pm2

  • archive project and copy onto host system
cd ..
tar -czvf <archive name>.tar.gz --exclude={"postgres-gtfs-rest-api/.git","postgres-gtfs-rest-api/node_modules"} postgres-gtfs-rest-api/
scp -P <host ssh port> <archive name>.tar.gz  <user>@<host>.<domain>:~
sudo tar -xzf ~/<archive name>.tar.gz -C /opt/
  • install dependencies
cd /opt/<archive name>
npm i
  • set up service environment on host system
sudo vi /opt/<archive name>/.env
  • define the following environment variables
DB_HOST=<host running database>
DB_PORT=<port of host running database>
DB_USER=<user granted permissions for database>
DB_PASSWORD=<user key>
DB_NAME=<database name>
NODE_ENV=<node environment mode>
PORT=<port offering this service>
  • setup pm2 like this

  • configure web server as proxy for instance with this example config file for Apache2

  • if service shall be provided to other consumers than localhost, adjust firewall accordingsly