Prerequisits:
- Node version 16.14.2
- NPM version 8.5.0
How to install: On a debian based linux (Like Ubuntu)
- Clone the repository and enter the directory with "cd" command
cd workorder
(As an example) - Run the command
npm i && cd frontend && npm i && npm run build && cd ..
- Rename the .env.example to .env
- Change the values in the .env fileds. (These are secrets... do not share them with anyone who does not need 100% access to the app)
- NODE_ENV should be set to 'production'
- PORT set to '5000'
- JWT_SECRET can be generated with the command
node -e "console.log(require('crypto').randomBytes(256).toString('base64'));"
- The other values are for the MySQL Database and Email Settings (coming soon)
How to deploy: (make sure you are in the project folder)
If you want to use a different method you can. This was initially set up for the person I made it for.
- Install the global package PM2 with the command with the command
sudo npm install pm2@latest -g
PM2 will start and restart the app in case it crashes or if there is a system reboot - Then run the command
pm2 start hello.js --name workorder
This will add the app to the PM2 process list and will auto start if a crash occurs. We can make it start with the system (in case of reboot) with the commandpm2 startup systemd
Which might give you another command to run from the output. (Just copy and paste the command if it gives you an output) - Save all of the changes to the PM2 process with the command
pm2 save
- In order to make sure that the system process for PM2 is running we will need to run the command
sudo systemctl start pm2
and confirm it is running withsystemctl status pm2
- Confirm the app is running in PM2 with the comamnd
pm2 list
-or-pm2 info workorder
The PM2 process monitor can be pulled up with the 'monit' subcommand. This displays the application status, CPU, and memory usage:pm2 monit
- Once that is done you will need to set a proxy_pass option in Nginx to the service with:
proxy_pass http://localhost:5000;
You will need to log in as the default user:
email: [email protected] password: 12345678 (Super secure... I know)Then register your own user and edit your user in MySQL to give your self the techRole of "admin" instead of the default or "user" (only user or admin roles are allowed currently