-
Create the file repository configuration:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
-
Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
-
Update the package lists:
sudo apt-get update
-
Install the latest version of PostgreSQL.
sudo apt-get -y install postgresql
-
Install node js
sudo apt install nodejs
-
Install npm
sudo apt install npm
-
Change directory to /opt
cd /opt
-
Clone the repository
git clone https://github.com/MoeinTavakoli/AlertHub.git
-
change directory to AlertHub directory and copy .env then fill the .env
cd AlertHub/ && cp .env.example .env
\ -
Install npm packages
npm i
-
Copy
.env.example
as.env.
cp .env.example .env
-
Create database in postgres
sudo -u postgres psql
create DATABASE alrerthub;
create user alrerthub with encrypted password 'alrerthub';
grant all privileges on database alrerthub to alrerthub;
ALTER USER alrerthub CREATEDB;
'\q' -
Fill the .env file
PORT
is your port that you want to server run on this port
HOST
is your hostname like localhost
DATABASE_URL
is url database like
this is format url connection postgrespostgres://YourUserName:YourPassword@YourHostname:5432/YourDatabaseName
SMS_APIKEY
is ApiKey that generate in dashboard kavenegrar
SMS_NUMBER
is your sms number that is exist in your dashboard kavenegar
SLACK_GP_ALERT_TOKEN
is your token to access in alert bot slack
SLACK_GP_ERROR_TOKEN
is your token to access in error bot slack
ROCKETCHAT_URL
is the url server rocketChat
JWT_SECRET
is your secret key for generate token (take care to keep it safe !!!)
ROOT_PASSWORD
is for root password that you -
Migrate database
npx prisma migrate dev
-
Seed database (just run once time )
npx prisma db seed
-
Edit config postgres
vim /etc/postgresql/14/main/postgresql.conf
uncomment:
listen_addresses= 'localhost'
-
Install pm2
npm install pm2@latest -g
-
Run server
pm2 start index.js