7d2e8009b655a2b6fae180a70ca0d5dfaa234ac3
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
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%