4.9 KiB
4.9 KiB
Install
Files needed to be downloaded before install.
To run the server
- PostgresSQL - current version using is 17
- NodeJS
- NSSM
To manage the server
Creating directories needed
- Create a new folder where we will host the server files.
- Copy the nssm.exe into this folder
- Copy the build files to the server (only needed for intial install).
- This will house all the compiles and minified files needed to start the server up, this includes the frontend.
- Save the nssm.exe into this folder as well, this will be used to control the service.
Do the intial install
DB instal setup
- Install postgres
- Open pgAdmin
- create a new Database named lst_db
Intial server setup
- Open VSCode and navigate to the folder where you extracted the files.
- Click trusted when it pops up.
- Open a terminal window inside vscode.
- Run the install script this will install all dependaceys needed as well as do all the database migrations
npm run prodinstall
Create the .env file
In the root of the folder create a new .env file add in the below and change each setting area that says change me to something that suits your needs
# PORTS
# To keep it all simple we will pass VITE to the ports that are used on both sides.
VITE_SERVER_PORT=4400
# logLevel
LOG_LEVEL=debug
# Auth stuff
SALTING=12
SECRET=CHANGEME
JWT_SECRET=CHANGEME
JWT_REFRESH_SECRET=CHANGEME
# Expire info plus refresh change as needed
JWT_EXPIRES=60
JWT_REFRESH_THRESHOLD=30
JWT_ACCESS_EXPIRATION="1h"
JWT_REFRESH_EXPIRATION="7d"
# this code will need to be used when a user needs to have access to everything.
SECRETOVERRIDECODE="supersecretKey"
# Database url - please change the password if this is all you changed
DATABASE_URL="postgresql://postgres:PASSWORD@localhost:5432/lst_db"
# This is for usday1 restrictions with the lgvs and customer constraints.
FIFO=100
MAXLOTS=3
Run the start command to get all the basic settings and modules installed
- Run the below
npm start
This command will start up the server and seed the database.
- Settings will be set here.
- All modules will be added.
- Press CTRL + C to stop the server.
- Reopen postgres and review the settings make the changes to match the server your going to be running in.
- Change the server
- change the dbServer
- change plantToken
- then the remaining settings confirm if you need on or want to leave as default.
Creating first user.
- Start the server back up.
npm start
- Open http://[SERVER]:[PORT]/api/docs or postman and create a user.
- Please do not try to manually enter a new user this is due to how the password is hashed, as well as setting systemAdmin for the first user.
- Change the server and port to what you changed in the DB.
- Stop the server again with CTRL + C.
Running as a serivice.
You want to CD into the scripts folder.
cd .\dist\server\scripts\
Next use the example command below to get the service up and running.
- Options legend
- serviceName = not recommended to change to reduce issues with the update process
- option = use install for the install, but you can use this script later to stop, start, restart the service.
- appPath = where did you extract the server files
- description = no need to change this unless you want it to be something else
- command = do not change this unless you know what your doing and really need to change this.
.\services.ps1 -serviceName "LSTV2" -option "install" -appPath "E:\LST\lstV2" -description "Logistics Support Tool V2" -command "run start"
Migrating From V1 to V2
User migration
- Open the sqlite db and export to sql the users table
- OPen the sql in notepad++ or your editor of choice and change the query to be similar to below.
- we only need to have save the username, role, email, password
An example new query will look like
- Below is how it looks when exported from sqlite
INSERT INTO "User" ("id", "username", "email", "role", "password", "passwordToken", "tokenExpire", "active", "pinCode", "lastLogin", "add_user", "add_date", "upd_user", "upd_date") VALUES
(1, 'matthes01', 'blake.matthes@alpla.com', 'admin', 'JDJiJDEMUJEdGtL', NULL, NULL, '1', NULL, '1721075647687', 'LST_System', '1721075647687', 'LST_System', '1721075647687');
The way we want to put recreate the query to work with the new db
- Below example
INSERT INTO "users" ("username", "email", "role", "password") VALUES
('matthes01','blake.matthes@alpla.com','admin','JDJiJDE1FuNFpkYlk4NGdHUXpEMzlHR1BD'),
('leland001','jordan.leland@alpla.com','manager','vekJhN1dIVVVZa3pxR1l0T2hX'),
('brandon001','brandon.harry@alpla.com','manager','wdm1RSXJlZnJDYTZP');
;
- You could have many users and just add like above with the identical info from the db