refactor(contorller): update to consider iowa_2 and look at plant token vs server going forward
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
|||||||
socketio "github.com/googollee/go-socket.io"
|
socketio "github.com/googollee/go-socket.io"
|
||||||
)
|
)
|
||||||
|
|
||||||
func copyBuild(server *socketio.Server, plant string, drive string) {
|
func copyBuild(server *socketio.Server, plant string, location string) {
|
||||||
// Load from environment in real-life code!
|
// Load from environment in real-life code!
|
||||||
user := os.Getenv("ADM_USER")
|
user := os.Getenv("ADM_USER")
|
||||||
pass := os.Getenv("ADM_PASS")
|
pass := os.Getenv("ADM_PASS")
|
||||||
@@ -21,7 +21,7 @@ func copyBuild(server *socketio.Server, plant string, drive string) {
|
|||||||
// latest build
|
// latest build
|
||||||
latestbuild := lastestBuild()
|
latestbuild := lastestBuild()
|
||||||
src := latestbuild
|
src := latestbuild
|
||||||
plantServer := fmt.Sprintf("\\\\%v\\%v$\\lst", plant, drive)
|
plantServer := fmt.Sprintf("\\\\%v\\%v", plant, location)
|
||||||
|
|
||||||
// Build PowerShell
|
// Build PowerShell
|
||||||
psScript := fmt.Sprintf(`
|
psScript := fmt.Sprintf(`
|
||||||
|
|||||||
@@ -32,6 +32,28 @@
|
|||||||
.error {
|
.error {
|
||||||
color: #f33;
|
color: #f33;
|
||||||
}
|
}
|
||||||
|
#server-buttons {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, 1fr); /* 4 equal columns */
|
||||||
|
gap: 0.75rem; /* roughly Tailwind gap-3 */
|
||||||
|
margin: 1rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#server-buttons button {
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
font-family: monospace;
|
||||||
|
border: 1px solid #444;
|
||||||
|
background: #222;
|
||||||
|
color: #eee;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
#server-buttons button:hover {
|
||||||
|
background: #333;
|
||||||
|
border-color: #888;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -74,15 +96,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="logWindow"></div>
|
<div id="logWindow"></div>
|
||||||
<div>
|
<div id="controls">
|
||||||
<button id="USMCD1VMS036">USMCD1VMS036</button>
|
<div id="server-buttons"></div>
|
||||||
<button id="USBET1VMS006">USBET1VMS006</button>
|
<button id="btnAll">Copy to ALL</button>
|
||||||
<button id="USBOW1VMS006">USBOW1VMS006</button>
|
|
||||||
<button id="USKSC1VMS006">USKSC1VMS006</button>
|
|
||||||
<button id="USMCD1VMS006">USMCD1VMS006</button>
|
|
||||||
<button id="USSLC1VMS006">USSLC1VMS006</button>
|
|
||||||
<button id="USSTP1VMS006">USSTP1VMS006</button>
|
|
||||||
<button id="USDAY1VMS006">USDAY1VMS006</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -98,6 +114,91 @@
|
|||||||
transports: ["polling"],
|
transports: ["polling"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const servers = [
|
||||||
|
{
|
||||||
|
name: "Test server",
|
||||||
|
server: "USMCD1VMS036",
|
||||||
|
location: "E$\\LST",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Bethlehem",
|
||||||
|
server: "USBET1VMS006",
|
||||||
|
location: "E$\\LST",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Bowling Green 1",
|
||||||
|
server: "USBOW1VMS006",
|
||||||
|
location: "E$\\LST",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Bowling Green 2",
|
||||||
|
server: "USBOW2VMS006",
|
||||||
|
location: "E$\\LST",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Flornece",
|
||||||
|
server: "USFLO1VMS006",
|
||||||
|
location: "E$\\LST",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Kasnas City",
|
||||||
|
server: "USKSC1VMS006",
|
||||||
|
location: "E$\\LST",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Marked Tree",
|
||||||
|
server: "USMAR1VMS006",
|
||||||
|
location: "E$\\LST",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "McDonough",
|
||||||
|
server: "USMCD1VMS006",
|
||||||
|
location: "E$\\LST",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Salt Lake City",
|
||||||
|
server: "USSLC1VMS006",
|
||||||
|
location: "E$\\LST",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "St.Peters",
|
||||||
|
server: "USSTP1VMS006",
|
||||||
|
location: "D$\\LST",
|
||||||
|
},
|
||||||
|
{ name: "Dayton", server: "USDAY1VMS006", location: "E$\\LST" },
|
||||||
|
{ name: "Lima", server: "USLIM1VMS006", location: "E$\\LST" },
|
||||||
|
{
|
||||||
|
name: "Iowa - EBM",
|
||||||
|
server: "USIOW1VMS006",
|
||||||
|
location: "D$\\LST\\LST",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Iowa - ISBM",
|
||||||
|
server: "USIOW1VMS006",
|
||||||
|
location: "D$\\LST\\LST_2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Houston",
|
||||||
|
server: "USHOU1VMS006",
|
||||||
|
location: "E$\\LST\\LST",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Sherman",
|
||||||
|
server: "USSHE1VMS006",
|
||||||
|
location: "E$\\LST\\LST",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "West Bend",
|
||||||
|
server: "USWEB1VMS006",
|
||||||
|
location: "E$\\LST\\LST",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Jerfferson City",
|
||||||
|
server: "USJCI1VMS006",
|
||||||
|
location: "E$\\LST\\LST",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
// log window reference
|
// log window reference
|
||||||
const logWindow = document.getElementById("logWindow");
|
const logWindow = document.getElementById("logWindow");
|
||||||
|
|
||||||
@@ -208,73 +309,89 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// all the server copy buttons
|
const serverButtonsDiv = document.getElementById("server-buttons");
|
||||||
document.getElementById("USMCD1VMS036").onclick = () => {
|
servers.forEach((srv) => {
|
||||||
socket.emit("update", {
|
const btn = document.createElement("button");
|
||||||
action: "copy",
|
btn.textContent = srv.name;
|
||||||
target: "USMCD1VMS036",
|
btn.dataset.server = srv.server;
|
||||||
drive: "e",
|
btn.dataset.drive = srv.drive;
|
||||||
}); // "frontend" = payload target
|
|
||||||
logMessage("info", "Copying to USMCD1VMS036");
|
btn.addEventListener("click", () => {
|
||||||
|
socket.emit("update", {
|
||||||
|
action: "copy",
|
||||||
|
target: srv.server,
|
||||||
|
location: srv.location,
|
||||||
|
});
|
||||||
|
logMessage(
|
||||||
|
"info",
|
||||||
|
`Copying to ${
|
||||||
|
srv.name
|
||||||
|
} (drive ${srv.drive.toUpperCase()})`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
serverButtonsDiv.appendChild(btn);
|
||||||
|
});
|
||||||
|
|
||||||
|
let copyQueue = []; // Holds list of servers left
|
||||||
|
let currentServer = null; // Track which server is waiting confirmation
|
||||||
|
let isRunningAll = false;
|
||||||
|
|
||||||
|
document.getElementById("btnAll").onclick = () => {
|
||||||
|
if (isRunningAll) {
|
||||||
|
logMessage("info", "⚠️ Copy to ALL already running...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
copyQueue = [...servers]; // fresh clone of the servers
|
||||||
|
isRunningAll = true;
|
||||||
|
logMessage(
|
||||||
|
"info",
|
||||||
|
"▶️ Starting sequential copy to ALL servers..."
|
||||||
|
);
|
||||||
|
|
||||||
|
runNextInQueue();
|
||||||
};
|
};
|
||||||
|
|
||||||
document.getElementById("USBET1VMS006").onclick = () => {
|
function runNextInQueue() {
|
||||||
socket.emit("update", {
|
if (copyQueue.length === 0) {
|
||||||
action: "copy",
|
logMessage("info", "✅ Finished copying to ALL servers!");
|
||||||
target: "USBET1VMS006",
|
isRunningAll = false;
|
||||||
drive: "e",
|
currentServer = null;
|
||||||
}); // "frontend" = payload target
|
return;
|
||||||
logMessage("info", "Copying to USBET1VMS006");
|
}
|
||||||
};
|
|
||||||
document.getElementById("USBOW1VMS006").onclick = () => {
|
currentServer = copyQueue.shift();
|
||||||
socket.emit("update", {
|
logMessage(
|
||||||
action: "copy",
|
"info",
|
||||||
target: "USBOW1VMS006",
|
`🚀 Copying to ${
|
||||||
drive: "e",
|
currentServer.name
|
||||||
}); // "frontend" = payload target
|
} (drive ${currentServer.drive.toUpperCase()})`
|
||||||
logMessage("info", "Copying to USBOW1VMS006");
|
);
|
||||||
};
|
|
||||||
document.getElementById("USSLC1VMS006").onclick = () => {
|
|
||||||
socket.emit("update", {
|
|
||||||
action: "copy",
|
|
||||||
target: "USSLC1VMS006",
|
|
||||||
drive: "e",
|
|
||||||
}); // "frontend" = payload target
|
|
||||||
logMessage("info", "Copying to USSLC1VMS006");
|
|
||||||
};
|
|
||||||
|
|
||||||
document.getElementById("USSTP1VMS006").onclick = () => {
|
|
||||||
socket.emit("update", {
|
socket.emit("update", {
|
||||||
action: "copy",
|
action: "copy",
|
||||||
target: "USSTP1VMS006",
|
target: currentServer.name,
|
||||||
drive: "d",
|
drive: currentServer.drive,
|
||||||
}); // "frontend" = payload target
|
});
|
||||||
logMessage("info", "Copying to USSTP1VMS006");
|
}
|
||||||
};
|
|
||||||
document.getElementById("USKSC1VMS006").onclick = () => {
|
socket.on("updateLogs", (msg) => {
|
||||||
socket.emit("update", {
|
//logMessage("update", msg);
|
||||||
action: "copy",
|
|
||||||
target: "USksc1VMS006",
|
// Only check queue progress if we're in All mode and have a currentServer
|
||||||
drive: "e",
|
if (isRunningAll && currentServer) {
|
||||||
}); // "frontend" = payload target
|
const expected = `✅ Copy to ${currentServer.name} successful`;
|
||||||
logMessage("info", "Copying to USKSC1VMS006");
|
|
||||||
};
|
if (msg.includes(expected)) {
|
||||||
document.getElementById("USDAY1VMS006").onclick = () => {
|
logMessage(
|
||||||
socket.emit("update", {
|
"info",
|
||||||
action: "copy",
|
`✅ Confirmed: ${currentServer.name} done`
|
||||||
target: "USDAY1VMS006",
|
);
|
||||||
drive: "e",
|
runNextInQueue(); // trigger the next server
|
||||||
}); // "frontend" = payload target
|
}
|
||||||
logMessage("info", "Copying to USDAY1VMS006");
|
}
|
||||||
};
|
});
|
||||||
document.getElementById("USMCD1VMS006").onclick = () => {
|
|
||||||
socket.emit("update", {
|
|
||||||
action: "copy",
|
|
||||||
target: "USMCD1VMS006",
|
|
||||||
drive: "e",
|
|
||||||
}); // "frontend" = payload target
|
|
||||||
logMessage("info", "Copying to USMCD1VMS006");
|
|
||||||
};
|
|
||||||
|
|
||||||
socket.on("logs", (msg) => logMessage("logs", msg));
|
socket.on("logs", (msg) => logMessage("logs", msg));
|
||||||
socket.on("errors", (msg) => logMessage("errors", msg));
|
socket.on("errors", (msg) => logMessage("errors", msg));
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type UpdatePayload struct {
|
type UpdatePayload struct {
|
||||||
Action string `json:"action"`
|
Action string `json:"action"`
|
||||||
Target string `json:"target"`
|
Target string `json:"target"`
|
||||||
Drive string `json:"drive"`
|
Location string `json:"location"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerUpdateChannel(server *socketio.Server) {
|
func registerUpdateChannel(server *socketio.Server) {
|
||||||
@@ -32,7 +32,7 @@ func registerUpdateChannel(server *socketio.Server) {
|
|||||||
server.OnEvent("/", "update", func(s socketio.Conn, payload UpdatePayload) {
|
server.OnEvent("/", "update", func(s socketio.Conn, payload UpdatePayload) {
|
||||||
switch strings.ToLower(payload.Action) {
|
switch strings.ToLower(payload.Action) {
|
||||||
case "copy":
|
case "copy":
|
||||||
copyLatestBuild(server, payload.Target, payload.Drive)
|
copyLatestBuild(server, payload.Target, payload.Location)
|
||||||
|
|
||||||
case "update":
|
case "update":
|
||||||
updateServer(server, payload.Target)
|
updateServer(server, payload.Target)
|
||||||
@@ -81,13 +81,13 @@ func updateServer(server *socketio.Server, target string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyLatestBuild(server *socketio.Server, target string, drive string) {
|
func copyLatestBuild(server *socketio.Server, target string, location string) {
|
||||||
server.BroadcastToRoom("/", "update", "updateLogs",
|
server.BroadcastToRoom("/", "update", "updateLogs",
|
||||||
fmt.Sprintf("🚀 Copying latest build to %v", target))
|
fmt.Sprintf("🚀 Copying latest build to %v", target))
|
||||||
copyBuild(server, target, drive)
|
copyBuild(server, target, location)
|
||||||
}
|
}
|
||||||
|
|
||||||
func triggerRemoteUpdate(server *socketio.Server, remoteURL string, payload UpdatePayload) {
|
func triggerRemoteUpdate(server *socketio.Server, token string, payload UpdatePayload) {
|
||||||
|
|
||||||
fmt.Println("running the update process")
|
fmt.Println("running the update process")
|
||||||
basePath := "/api/controller"
|
basePath := "/api/controller"
|
||||||
@@ -98,7 +98,7 @@ func triggerRemoteUpdate(server *socketio.Server, remoteURL string, payload Upda
|
|||||||
// send POST request with JSON, expect SSE / streaming text back
|
// send POST request with JSON, expect SSE / streaming text back
|
||||||
body, _ := json.Marshal(payload)
|
body, _ := json.Marshal(payload)
|
||||||
|
|
||||||
url := fmt.Sprintf("https://%v.alpla.net%v/update", remoteURL, basePath)
|
url := fmt.Sprintf("https://%vprod.alpla.net%v/update", token, basePath)
|
||||||
fmt.Println(url)
|
fmt.Println(url)
|
||||||
//url := fmt.Sprintf("http://%v:8080/api/controller/update", remoteURL)
|
//url := fmt.Sprintf("http://%v:8080/api/controller/update", remoteURL)
|
||||||
fmt.Println(url)
|
fmt.Println(url)
|
||||||
|
|||||||
@@ -14,24 +14,28 @@ param (
|
|||||||
# example string to pass over, you must be in the script dir when you run this script. or it will fail to find the linked scripts
|
# example string to pass over, you must be in the script dir when you run this script. or it will fail to find the linked scripts
|
||||||
|
|
||||||
# If we do not pass plant to update over it will auto do all plants if we want a specific plant we need to do like below
|
# If we do not pass plant to update over it will auto do all plants if we want a specific plant we need to do like below
|
||||||
# .\update-controllers.ps1 -App_Path "C:\Users\matthes01\Documents\lst" -Token "usiow2" -BuildController no -PlantToUpdate "usiow1vms006" -Remote_Path "D$\LST\lst_2"
|
# .\update-controllers.ps1 -App_Path "C:\Users\matthes01\Documents\lst" -Token "usstp1" -BuildController yes -PlantToUpdate "usstp1vms006" -Remote_Path "D$\LST"
|
||||||
# .\update-controllers.ps1 -App_Path "C:\Users\matthes01\Documents\lst" -Token "test3" -BuildController yes
|
# .\update-controllers.ps1 -App_Path "C:\Users\matthes01\Documents\lst" -Token "test3" -BuildController yes
|
||||||
|
|
||||||
$Plants = @(
|
$Plants = @(
|
||||||
@{ Server = "usmcd1vms036"; Token = "test3"; Remote_Path = "E$\LST" }
|
@{ Server = "usmcd1vms036"; Token = "test3"; Remote_Path = "E$\LST" }
|
||||||
@{ Server = "usmar1vms006"; Token = "usmar1" ; Remote_Path = "E$\LST" }
|
@{ Server = "usmar1vms006"; Token = "usmar1" ; Remote_Path = "E$\LST" }
|
||||||
@{ Server = "usbet1vms006"; Token = "usbet1"; Remote_Path = "E$\LST" }
|
@{ Server = "usbet1vms006"; Token = "usbet1"; Remote_Path = "E$\LST" }
|
||||||
@{ Server = "usbow1vms006"; Token = "usbow1" ; Remote_Path = "E$\LST" }
|
@{ Server = "usbow1vms006"; Token = "usbow1" ; Remote_Path = "E$\LST" }
|
||||||
@{ Server = "usbow2vms006"; Token = "usbow2" ; Remote_Path = "E$\LST" }
|
@{ Server = "usbow2vms006"; Token = "usbow2" ; Remote_Path = "E$\LST" }
|
||||||
@{ Server = "usday1vms006"; Token = "usday1" ; Remote_Path = "E$\LST" }
|
@{ Server = "usday1vms006"; Token = "usday1" ; Remote_Path = "E$\LST" }
|
||||||
@{ Server = "usflo1vms006"; Token = "usflo1" ; Remote_Path = "E$\LST" }
|
@{ Server = "usflo1vms006"; Token = "usflo1" ; Remote_Path = "E$\LST" }
|
||||||
@{ Server = "usiow1vms006"; Token = "usiow1" ; Remote_Path = "D$\LST\lst" }
|
@{ Server = "usiow1vms006"; Token = "usiow1" ; Remote_Path = "D$\LST\lst" }
|
||||||
@{ Server = "usiow1vms006"; Token = "usiow2" ; Remote_Path = "D$\LST\lst_2" }
|
@{ Server = "usiow1vms006"; Token = "usiow2" ; Remote_Path = "D$\LST\lst_2" }
|
||||||
@{ Server = "uslim1vms006"; Token = "uslim1" ; Remote_Path = "E$\LST" }
|
@{ Server = "uslim1vms006"; Token = "uslim1" ; Remote_Path = "E$\LST" }
|
||||||
@{ Server = "usmcd1vms006"; Token = "usmcd1" ; Remote_Path = "E$\LST" }
|
@{ Server = "usmcd1vms006"; Token = "usmcd1" ; Remote_Path = "E$\LST" }
|
||||||
@{ Server = "usslc1vms006"; Token = "usslc1" ; Remote_Path = "E$\LST" }
|
@{ Server = "usslc1vms006"; Token = "usslc1" ; Remote_Path = "E$\LST" }
|
||||||
@{ Server = "usstp1vms006"; Token = "usstp1" ; Remote_Path = "D$\LST" }
|
@{ Server = "usstp1vms006"; Token = "usstp1" ; Remote_Path = "D$\LST" }
|
||||||
@{ Server = "usksc1vms006"; Token = "usksc1" ; Remote_Path = "E$\LST" }
|
@{ Server = "usksc1vms006"; Token = "usksc1" ; Remote_Path = "E$\LST" }
|
||||||
|
@{ Server = "ushou1vms006"; Token = "ushou1" ; Remote_Path = "E$\LST" } #15
|
||||||
|
@{ Server = "usshe1vms006"; Token = "usshe1" ; Remote_Path = "E$\LST" }#16
|
||||||
|
@{ Server = "usweb1vms006"; Token = "usweb1" ; Remote_Path = "E$\LST" }#17
|
||||||
|
@{ Server = "usjci1vms006"; Token = "usjci1" ; Remote_Path = "E$\LST" }
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user