d27946ed885d916e5a2acb30d3d9b02db077e5ed
BioProAPIServer
Setup pi3 postgresql
Switch to the Postgres user to configure the database
sudo su postgres
Create a database user 'biopro' with password 'BioProControlBox'
createuser biopro -P --interactive
Postgres command (type psql first to connect postgres)
#Find databases
\l
#Find tables
\dt
Run apiServer on device
Install node.js
sudo apt-get upgrade
sudo apt-get update
### setup_14.x can change to your version
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
### install node and npm
sudo apt-get install -y nodejs
(optional) if the installation of node.js fail
sudo apt update
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Clone project
git clone https://gitlab.com/bioproscientific/bioproapiserver.git
Change config port
cd ~/bioproapiserver/src
vim config.js
change the code following as:
/*
change apiserver port to postgres port, 54321 --> 5432 (default)
*/
export const pgDB = {
host: '127.0.0.1', // 服务器地址
port: 54321, // 数据库端口号 -----------------> 5432
username: 'biopro', // 数据库用户名
password: 'BioProControlBox', // 数据库密码
database: 'postgres' // 数据库名称
}
Init setup project && build dist app
cd ~/bioproapiserver
npm install
npm run build
Auto run program when pi-start
sudo vim /etc/rc.local
add the code following as:
nohup node /home/pi/bioproapiserver/dist/app.js > /home/pi/.api_server.out &
Localhost develop
Localhost test port binding (your device:54321 -> raspberrypi:5432)
ssh -NL 54321:localhost:5432 pi@your-pi3-ip
Run apiServer on your localhost (remember binding port first)
git clone https://gitlab.com/bioproscientific/bioproapiserver.git
cd bioproapiserver
npm install
npm run start
References
https://opensource.com/article/17/10/set-postgres-database-your-raspberry-pi
Languages
JavaScript
95.1%
Python
4.5%
Dockerfile
0.3%