base-station
system architecture
Necessary steps before running
- In the client directory, run:
npm install
npm install
installs the necessary dependencies for the client app
- In the node -server directory, run:
installs the necessary dependencies for the server app
How to run in production environment
In the node-server directory, run:
npm run prod
How to run in development environment
In the node-server directory, you can run:
npm run dev
Runs the app in the development mode. Open http://localhost:3000 to view it in your browser.
Running with custom environment variables on client
- In the client directory create a .env.local file
touch .env.local
- Add the following values to the .env.local file
REACT_APP_SERVER_URL=ws://<server hostname or ip address>:<server port> or http://<server hostname or ip address>:<server port>
Running with custom environment variables on server
- In the node-server directory create a .env file
touch .env
- Add the following values to the .env file
BROKER_URL=mqtt://<broker hostname or ip address>:<broker port>
PORT=<server port>
ORIGIN=http://<client hostname or ip address>:<client port>
Running with systemd
Suppose you are in the app directory /home/$USER/foo
- Create file, let’s call it foo.service
touch foo.service
- In the file add
[Unit]
Description=Foo application
[Service]
User=<USER>
WorkingDirectory=/home/<USER>/foo
ExecStart=/usr/bin/npm run prod
Restart=on-failure
[Install]
WantedBy=multi-user.target
- Copy unit into systemd folder
sudo cp foo.service /etc/systemd/system
- Reload daemon
sudo systemctl daemon-reload
- Enable start on boot
sudo systemctl enable foo.service
systemd on raspberrypi example
Suppose you are in the app directory /home/pi/Desktop/base-station
- Create file, let’s call it bs.service
touch bs.service
- In the file add
[Unit]
Description=Nakuja N2 base station software
[Service]
User=pi
WorkingDirectory=/home/pi/Desktop/base-station
ExecStart=/usr/bin/npm run prod
Restart=on-failure
[Install]
WantedBy=multi-user.target
- Copy unit into systemd folder
sudo cp bs.service /etc/systemd/system
- Reload daemon
sudo systemctl daemon-reload
- Enable start on boot
sudo systemctl enable bs.service