-
diff --git a/frontend/src/components/admin/servers/UpdateServer.tsx b/frontend/src/components/admin/servers/UpdateServer.tsx
index be12938..2b0eb7e 100644
--- a/frontend/src/components/admin/servers/UpdateServer.tsx
+++ b/frontend/src/components/admin/servers/UpdateServer.tsx
@@ -1,23 +1,34 @@
-import {Button} from "@/components/ui/button";
-import {CircleFadingArrowUp} from "lucide-react";
-import {toast} from "sonner";
-import {Servers} from "./ServerPage";
-import {useQuery} from "@tanstack/react-query";
-import {getSettings} from "@/utils/querys/settings";
+import { Button } from "@/components/ui/button";
+import { CircleFadingArrowUp } from "lucide-react";
+import { toast } from "sonner";
+import { Servers } from "./ServerPage";
+import { useQuery } from "@tanstack/react-query";
+import { getSettings } from "@/utils/querys/settings";
import axios from "axios";
-import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from "@/components/ui/tooltip";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
-export default function UpdateServer({server, token}: {server: Servers; token: string}) {
- const {data} = useQuery(getSettings(token ?? ""));
+export default function UpdateServer({
+ server,
+ token,
+}: {
+ server: Servers;
+ token: string;
+}) {
+ const { data } = useQuery(getSettings(token ?? ""));
const upgrade = async () => {
let devDir = data.filter((n: any) => n.name === "devDir");
toast.success("Server being upgraded in the background please wait.");
try {
const result = await axios.post(
`/api/server/update/${server.plantToken}`,
- {devDir: devDir[0].value},
+ { devDir: devDir[0].value },
{
- headers: {Authorization: `Bearer ${token}`},
+ headers: { Authorization: `Bearer ${token}` },
}
);
@@ -29,7 +40,9 @@ export default function UpdateServer({server, token}: {server: Servers; token: s
toast.success(result.data.message);
}
} catch (error: any) {
- toast.error(`There was an error updating the server: ${error.data.message}`);
+ toast.error(
+ `There was an error updating the server: ${error.data.message}`
+ );
}
};
return (
@@ -37,7 +50,12 @@ export default function UpdateServer({server, token}: {server: Servers; token: s
-
+
diff --git a/server/scripts/install.md b/server/scripts/install.md
index d4d8133..681beeb 100644
--- a/server/scripts/install.md
+++ b/server/scripts/install.md
@@ -4,22 +4,22 @@
### To run the server
-- [PostgresSQL](https://www.postgresql.org/download/windows/) - current version using is 17
-- [NodeJS](https://nodejs.org)
-- [NSSM](https://nssm.cc/)
+- [PostgresSQL](https://www.postgresql.org/download/windows/) - current version using is 17
+- [NodeJS](https://nodejs.org)
+- [NSSM](https://nssm.cc/)
### To manage the server
-- [VSCODE](https://code.visualstudio.com/)
-- [Postman](https://www.postman.com/downloads/)
+- [VSCODE](https://code.visualstudio.com/)
+- [Postman](https://www.postman.com/downloads/)
## 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.
+- 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
@@ -53,14 +53,12 @@ add in the below and change each setting area that says change me to something t
```env
# PORTS
+PROD_PORT=4000
# To keep it all simple we will pass VITE to the ports that are used on both sides.
-VITE_SERVER_PORT=4400
+VITE_SERVER_PORT=4000
# logLevel
-LOG_LEVEL=debug
-PROD_PORT=4000
-# DUE to lstv1 we need 3000
-SEC_PORT=3000
+LOG_LEVEL=info
# Auth stuff
SALTING=12
SECRET=CHANGEME
@@ -94,15 +92,15 @@ npm start
This command will start up the server and seed the database.
-- Settings will be set here.
-- All modules will be added.
+- Settings will be set here.
+- All modules will be added.
2. Press CTRL + C to stop the server.
3. 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.
+ - 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.
@@ -113,8 +111,8 @@ npm start
```
2. 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.
+ - 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.
3. Stop the server again with CTRL + C.
### Running as a serivice.
@@ -127,28 +125,58 @@ 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.
+- 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.
```powershell
.\services.ps1 -serviceName "LSTV2" -option "install" -appPath "E:\LST\lstV2" -description "Logistics Support Tool V2" -command "run start"
```
+### Adding servers to the mix to update on from the front end
+
+you will need to add your servers into the serverData.json.
+when the server starts up it will look at this file and make changes as needed.
+below is an example of the server
+
+```JSON
+{
+ "sName": "Kansas City",
+ "serverDNS": "usksc1vms006",
+ "plantToken": "usksc1",
+ "idAddress": "10.42.9.26",
+ "greatPlainsPlantCode": "85",
+ "streetAddress": "1800 E 94th St Suite 300",
+ "cityState": "Kansas City, MO",
+ "zipcode": "64131",
+ "contactEmail": "example@example.com",
+ "contactPhone": "555-555-5555",
+ "customerTiAcc": "ALPL01KCINT",
+ "lstServerPort": "4000",
+ "active": false,
+ "serverLoc": "E:\\LST\\lstv2",
+ "oldVersion": "E:\\LST\\lst_backend",
+ "shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
+ "tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
+ "otherSettings": [{ "specialInstructions": "" }]
+}
+
+```
+
# Migrating From V1 to V2
## User migration
1. Open the sqlite db and export to sql the users table
2. 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
+ - 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
+- Below is how it looks when exported from sqlite
```sql
INSERT INTO "User" ("id", "username", "email", "role", "password", "passwordToken", "tokenExpire", "active", "pinCode", "lastLogin", "add_user", "add_date", "upd_user", "upd_date") VALUES
@@ -157,7 +185,7 @@ INSERT INTO "User" ("id", "username", "email", "role", "password", "passwordToke
The way we want to put recreate the query to work with the new db
-- Below example
+- Below example
```sql
INSERT INTO "users" ("username", "email", "role", "password") VALUES
@@ -167,11 +195,11 @@ INSERT INTO "users" ("username", "email", "role", "password") VALUES
;
```
-- You could have many users and just add like above with the identical info from the db
+- You could have many users and just add like above with the identical info from the db
## Running v1 along Side V2 for the interm
-- change v2 prod port to 4000 in the env and db
-- change v1 env to 4400 in the env. and in the db you will need to change the auth server to 4000 and the serverPort to 4400
+- change v2 prod port to 4000 in the env and db
+- change v1 env to 4400 in the env. and in the db you will need to change the auth server to 4000 and the serverPort to 4400
This will change so that v2 is the main server now, this is needed for ocme mainly.
diff --git a/server/scripts/services.ps1 b/server/scripts/services.ps1
index 35014cb..045830d 100644
--- a/server/scripts/services.ps1
+++ b/server/scripts/services.ps1
@@ -4,6 +4,7 @@ param (
[string]$appPath,
[string]$command, # just the command like run startadm or what ever you have in npm.
[string]$description
+ [string]$remote
)
# Example string to run with the parameters in it.
@@ -24,6 +25,16 @@ param (
$nssmPath = $AppPath + "\nssm.exe"
$npmPath = "C:\Program Files\nodejs\npm.cmd" # Path to npm.cmd
+if($remote -eq "true"){
+ $plantFunness = {
+ param ($service, $processType, $location)
+ # Call your PowerShell script inside plantFunness
+ & "$($location)\dist\server\scripts\services.ps1" -serviceName $service -option $processType -appPath $location
+ }
+
+ Invoke-Command -ComputerName $server -ScriptBlock $plantFunness -ArgumentList $service, $option, $appPath -Credential $credentials
+}
+
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Host "Error: This script must be run as Administrator."
exit 1
diff --git a/server/scripts/update.ps1 b/server/scripts/update.ps1
index a9da3fc..fc1f735 100644
--- a/server/scripts/update.ps1
+++ b/server/scripts/update.ps1
@@ -132,6 +132,17 @@ $plantFunness = {
exit 1 # Exit with a non-zero code if there's an error
}
+ # for iowa 2 need to change the port config on the start up of nextjs server
+ if($token -eq "usiow2"){
+ $jsonPkgloc = "$($obslst)\apps\frontend\package.json"
+ #read the file
+ $jsonContent = Get-Content -Path $jsonPkgloc | ConvertFrom-Json
+ #change the second we want to update
+ $jsonContent.scripts.start = "next start -p 3001"
+ # convert back to json
+ $jsonContent | ConvertTo-Json | Set-Content -Path $jsonPkgloc
+ }
+
############################################################################
Write-Host "Stopping the services to do the updates, pkgs and db changes."
diff --git a/tsconfig.json b/tsconfig.json
index 62edf87..27fc5d0 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -15,6 +15,10 @@
"esModuleInterop": true,
"resolveJsonModule": true
},
- "include": ["server", "scripts/**/*.ts", "testFiles/test-tiPostOrders.ts"],
- "exclude": ["node_modules", "frontend", "dist", "testFiles"]
+ "include": [
+ "server",
+ "scripts/**/*.ts",
+ "database/testFiles/test-tiPostOrders.ts"
+ ],
+ "exclude": ["node_modules", "frontend", "dist", "database/testFiles"]
}