Compare commits

...

8 Commits

Author SHA1 Message Date
renovate[bot]
8f3a4b3eef fix(deps): update dependency lucide-react to ^0.552.0 2025-10-31 11:08:50 +00:00
9 Technology Group LTD
f3bca4a6d5 Merge pull request #245 from alan7000/alan7000-patch-1
Enable listen IPv6 for port 3000
2025-10-29 20:39:29 +00:00
Flambard alan
ca4d34c230 Enable listen IPv6 for port 3000 2025-10-29 17:07:50 +01:00
9 Technology Group LTD
1e75f2b1fe Merge pull request #242 from PatchMon/release/1-3-1
Agent update initiation from server
2025-10-28 21:55:57 +00:00
Muhammad Ibrahim
79317b0052 Added server initiated Agent update 2025-10-28 21:49:19 +00:00
Muhammad Ibrahim
77a945a5b6 fix: add Prisma connection pool variables to update_env_file function
- Added DB_CONNECTION_LIMIT, DB_POOL_TIMEOUT, DB_CONNECT_TIMEOUT, DB_IDLE_TIMEOUT, DB_MAX_LIFETIME
- Sets defaults (30, 20, 10, 300, 1800) if not already in .env
- Checks for missing variables during update mode
- Automatically adds them with comment header
- Ensures existing installations get connection pool settings on update
2025-10-28 19:55:42 +00:00
9 Technology Group LTD
276d910e83 Merge pull request #238 from PatchMon/release/1-3-1
fix: handle non-git installations in update mode
2025-10-28 19:33:22 +00:00
Muhammad Ibrahim
dae536e96b fix: handle non-git installations in update mode
- Added fallback to re-initialize git repository if .git directory missing
- Automatically detects current version from package.json
- Attempts to match to correct release branch
- Falls back to main branch if version detection fails
- Prevents update failures for legacy installations
2025-10-28 19:21:11 +00:00
13 changed files with 470 additions and 9 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1430,6 +1430,69 @@ router.patch(
}, },
); );
// Force agent update for specific host
router.post(
"/:hostId/force-agent-update",
authenticateToken,
requireManageHosts,
async (req, res) => {
try {
const { hostId } = req.params;
// Get host to verify it exists
const host = await prisma.hosts.findUnique({
where: { id: hostId },
});
if (!host) {
return res.status(404).json({ error: "Host not found" });
}
// Get queue manager
const { QUEUE_NAMES } = require("../services/automation");
const queueManager = req.app.locals.queueManager;
if (!queueManager) {
return res.status(500).json({
error: "Queue manager not available",
});
}
// Get the agent-commands queue
const queue = queueManager.queues[QUEUE_NAMES.AGENT_COMMANDS];
// Add job to queue
await queue.add(
"update_agent",
{
api_id: host.api_id,
type: "update_agent",
},
{
attempts: 3,
backoff: {
type: "exponential",
delay: 2000,
},
},
);
res.json({
success: true,
message: "Agent update queued successfully",
host: {
id: host.id,
friendlyName: host.friendly_name,
apiId: host.api_id,
},
});
} catch (error) {
console.error("Force agent update error:", error);
res.status(500).json({ error: "Failed to force agent update" });
}
},
);
// Serve the installation script (requires API authentication) // Serve the installation script (requires API authentication)
router.get("/install", async (req, res) => { router.get("/install", async (req, res) => {
try { try {

View File

@@ -176,6 +176,15 @@ function pushSettingsUpdate(apiId, newInterval) {
); );
} }
function pushUpdateAgent(apiId) {
const ws = apiIdToSocket.get(apiId);
safeSend(ws, JSON.stringify({ type: "update_agent" }));
}
function getConnectionByApiId(apiId) {
return apiIdToSocket.get(apiId);
}
function pushUpdateNotification(apiId, updateInfo) { function pushUpdateNotification(apiId, updateInfo) {
const ws = apiIdToSocket.get(apiId); const ws = apiIdToSocket.get(apiId);
if (ws && ws.readyState === WebSocket.OPEN) { if (ws && ws.readyState === WebSocket.OPEN) {
@@ -330,10 +339,12 @@ module.exports = {
broadcastSettingsUpdate, broadcastSettingsUpdate,
pushReportNow, pushReportNow,
pushSettingsUpdate, pushSettingsUpdate,
pushUpdateAgent,
pushUpdateNotification, pushUpdateNotification,
pushUpdateNotificationToAll, pushUpdateNotificationToAll,
// Expose read-only view of connected agents // Expose read-only view of connected agents
getConnectedApiIds: () => Array.from(apiIdToSocket.keys()), getConnectedApiIds: () => Array.from(apiIdToSocket.keys()),
getConnectionByApiId,
isConnected: (apiId) => { isConnected: (apiId) => {
const ws = apiIdToSocket.get(apiId); const ws = apiIdToSocket.get(apiId);
return !!ws && ws.readyState === WebSocket.OPEN; return !!ws && ws.readyState === WebSocket.OPEN;

View File

@@ -190,6 +190,19 @@ class QueueManager {
// For settings update, we need additional data // For settings update, we need additional data
const { update_interval } = job.data; const { update_interval } = job.data;
agentWs.pushSettingsUpdate(api_id, update_interval); agentWs.pushSettingsUpdate(api_id, update_interval);
} else if (type === "update_agent") {
// Force agent to update by sending WebSocket command
const ws = agentWs.getConnectionByApiId(api_id);
if (ws && ws.readyState === 1) {
// WebSocket.OPEN
agentWs.pushUpdateAgent(api_id);
console.log(`✅ Update command sent to agent ${api_id}`);
} else {
console.error(`❌ Agent ${api_id} is not connected`);
throw new Error(
`Agent ${api_id} is not connected. Cannot send update command.`,
);
}
} else { } else {
console.error(`Unknown agent command type: ${type}`); console.error(`Unknown agent command type: ${type}`);
} }

View File

@@ -1,5 +1,6 @@
server { server {
listen 3000; listen 3000;
listen [::]:3000;
server_name localhost; server_name localhost;
root /usr/share/nginx/html; root /usr/share/nginx/html;
index index.html; index index.html;

View File

@@ -22,7 +22,7 @@
"date-fns": "^4.1.0", "date-fns": "^4.1.0",
"express": "^4.21.2", "express": "^4.21.2",
"http-proxy-middleware": "^3.0.3", "http-proxy-middleware": "^3.0.3",
"lucide-react": "^0.468.0", "lucide-react": "^0.552.0",
"react": "^18.3.1", "react": "^18.3.1",
"react-chartjs-2": "^5.2.0", "react-chartjs-2": "^5.2.0",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",

View File

@@ -187,6 +187,16 @@ const HostDetail = () => {
}, },
}); });
// Force agent update mutation
const forceAgentUpdateMutation = useMutation({
mutationFn: () =>
adminHostsAPI.forceAgentUpdate(hostId).then((res) => res.data),
onSuccess: () => {
queryClient.invalidateQueries(["host", hostId]);
queryClient.invalidateQueries(["hosts"]);
},
});
const updateFriendlyNameMutation = useMutation({ const updateFriendlyNameMutation = useMutation({
mutationFn: (friendlyName) => mutationFn: (friendlyName) =>
adminHostsAPI adminHostsAPI
@@ -703,6 +713,29 @@ const HostDetail = () => {
/> />
</button> </button>
</div> </div>
<div>
<p className="text-xs text-secondary-500 dark:text-secondary-300 mb-1.5">
Force Update
</p>
<button
type="button"
onClick={() => forceAgentUpdateMutation.mutate()}
disabled={forceAgentUpdateMutation.isPending}
className="flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20 border border-primary-200 dark:border-primary-800 rounded-md hover:bg-primary-100 dark:hover:bg-primary-900/40 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
>
<RefreshCw
className={`h-3 w-3 ${
forceAgentUpdateMutation.isPending
? "animate-spin"
: ""
}`}
/>
{forceAgentUpdateMutation.isPending
? "Updating..."
: "Update Now"}
</button>
</div>
</div> </div>
</div> </div>
)} )}

View File

@@ -95,6 +95,7 @@ export const adminHostsAPI = {
api.put("/hosts/bulk/groups", { hostIds, groupIds }), api.put("/hosts/bulk/groups", { hostIds, groupIds }),
toggleAutoUpdate: (hostId, autoUpdate) => toggleAutoUpdate: (hostId, autoUpdate) =>
api.patch(`/hosts/${hostId}/auto-update`, { auto_update: autoUpdate }), api.patch(`/hosts/${hostId}/auto-update`, { auto_update: autoUpdate }),
forceAgentUpdate: (hostId) => api.post(`/hosts/${hostId}/force-agent-update`),
updateFriendlyName: (hostId, friendlyName) => updateFriendlyName: (hostId, friendlyName) =>
api.patch(`/hosts/${hostId}/friendly-name`, { api.patch(`/hosts/${hostId}/friendly-name`, {
friendly_name: friendlyName, friendly_name: friendlyName,

267
package-lock.json generated
View File

@@ -73,7 +73,7 @@
"date-fns": "^4.1.0", "date-fns": "^4.1.0",
"express": "^4.21.2", "express": "^4.21.2",
"http-proxy-middleware": "^3.0.3", "http-proxy-middleware": "^3.0.3",
"lucide-react": "^0.468.0", "lucide-react": "^0.552.0",
"react": "^18.3.1", "react": "^18.3.1",
"react-chartjs-2": "^5.2.0", "react-chartjs-2": "^5.2.0",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",
@@ -134,6 +134,7 @@
"version": "7.28.4", "version": "7.28.4",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.27.1", "@babel/code-frame": "^7.27.1",
"@babel/generator": "^7.28.3", "@babel/generator": "^7.28.3",
@@ -386,6 +387,74 @@
"@biomejs/cli-win32-x64": "2.3.0" "@biomejs/cli-win32-x64": "2.3.0"
} }
}, },
"node_modules/@biomejs/cli-darwin-arm64": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.3.0.tgz",
"integrity": "sha512-3cJVT0Z5pbTkoBmbjmDZTDFYxIkRcrs9sYVJbIBHU8E6qQxgXAaBfSVjjCreG56rfDuQBr43GzwzmaHPcu4vlw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-darwin-x64": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.3.0.tgz",
"integrity": "sha512-6LIkhglh3UGjuDqJXsK42qCA0XkD1Ke4K/raFOii7QQPbM8Pia7Qj2Hji4XuF2/R78hRmEx7uKJH3t/Y9UahtQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-linux-arm64": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.3.0.tgz",
"integrity": "sha512-uhAsbXySX7xsXahegDg5h3CDgfMcRsJvWLFPG0pjkylgBb9lErbK2C0UINW52zhwg0cPISB09lxHPxCau4e2xA==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-linux-arm64-musl": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.3.0.tgz",
"integrity": "sha512-nDksoFdwZ2YrE7NiYDhtMhL2UgFn8Kb7Y0bYvnTAakHnqEdb4lKindtBc1f+xg2Snz0JQhJUYO7r9CDBosRU5w==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-linux-x64": { "node_modules/@biomejs/cli-linux-x64": {
"version": "2.3.0", "version": "2.3.0",
"cpu": [ "cpu": [
@@ -401,6 +470,57 @@
"node": ">=14.21.3" "node": ">=14.21.3"
} }
}, },
"node_modules/@biomejs/cli-linux-x64-musl": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.3.0.tgz",
"integrity": "sha512-+i9UcJwl99uAhtRQDz9jUAh+Xkb097eekxs/D9j4deWDg5/yB/jPWzISe1nBHvlzTXsdUSj0VvB4Go2DSpKIMw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-win32-arm64": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.3.0.tgz",
"integrity": "sha512-ynjmsJLIKrAjC3CCnKMMhzcnNy8dbQWjKfSU5YA0mIruTxBNMbkAJp+Pr2iV7/hFou+66ZSD/WV8hmLEmhUaXA==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@biomejs/cli-win32-x64": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.3.0.tgz",
"integrity": "sha512-zOCYmCRVkWXc9v8P7OLbLlGGMxQTKMvi+5IC4v7O8DkjLCOHRzRVK/Lno2pGZNo0lzKM60pcQOhH8HVkXMQdFg==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT OR Apache-2.0",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=14.21.3"
}
},
"node_modules/@bull-board/api": { "node_modules/@bull-board/api": {
"version": "6.13.1", "version": "6.13.1",
"license": "MIT", "license": "MIT",
@@ -424,6 +544,7 @@
"node_modules/@bull-board/ui": { "node_modules/@bull-board/ui": {
"version": "6.13.1", "version": "6.13.1",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@bull-board/api": "6.13.1" "@bull-board/api": "6.13.1"
} }
@@ -457,6 +578,7 @@
"node_modules/@dnd-kit/core": { "node_modules/@dnd-kit/core": {
"version": "6.3.1", "version": "6.3.1",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@dnd-kit/accessibility": "^3.1.1", "@dnd-kit/accessibility": "^3.1.1",
"@dnd-kit/utilities": "^3.2.2", "@dnd-kit/utilities": "^3.2.2",
@@ -897,6 +1019,7 @@
"version": "18.3.24", "version": "18.3.24",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@types/prop-types": "*", "@types/prop-types": "*",
"csstype": "^3.0.2" "csstype": "^3.0.2"
@@ -1144,6 +1267,7 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"baseline-browser-mapping": "^2.8.3", "baseline-browser-mapping": "^2.8.3",
"caniuse-lite": "^1.0.30001741", "caniuse-lite": "^1.0.30001741",
@@ -1333,6 +1457,7 @@
"node_modules/chart.js": { "node_modules/chart.js": {
"version": "4.5.0", "version": "4.5.0",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@kurkle/color": "^0.3.0" "@kurkle/color": "^0.3.0"
}, },
@@ -1907,6 +2032,7 @@
"node_modules/express": { "node_modules/express": {
"version": "4.21.2", "version": "4.21.2",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"accepts": "~1.3.8", "accepts": "~1.3.8",
"array-flatten": "1.1.1", "array-flatten": "1.1.1",
@@ -2672,6 +2798,76 @@
"lefthook-windows-x64": "1.13.5" "lefthook-windows-x64": "1.13.5"
} }
}, },
"node_modules/lefthook-darwin-arm64": {
"version": "1.13.5",
"resolved": "https://registry.npmjs.org/lefthook-darwin-arm64/-/lefthook-darwin-arm64-1.13.5.tgz",
"integrity": "sha512-BYt5CnAOXasVCS6i+A4ljUo9xru/B5uMFD6EWHhs3R26jGF7mBSDxM3ErzXTUaJRTP0kQI/XBmgqBryBqoqZOQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
]
},
"node_modules/lefthook-darwin-x64": {
"version": "1.13.5",
"resolved": "https://registry.npmjs.org/lefthook-darwin-x64/-/lefthook-darwin-x64-1.13.5.tgz",
"integrity": "sha512-ZDtLBzvI5e26C/RZ4irOHpELTd22x9lDTgF2+eCYcnrBWOkB7800V8tuAvBybsLGvg6JwKjFxn+NTRNZnCC2hw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
]
},
"node_modules/lefthook-freebsd-arm64": {
"version": "1.13.5",
"resolved": "https://registry.npmjs.org/lefthook-freebsd-arm64/-/lefthook-freebsd-arm64-1.13.5.tgz",
"integrity": "sha512-uQ/kQZSSedw74aGCpsfOPN4yVt3klg8grOP6gHQOCRUMv5oK/Lj3pe1PylpTuuhxWORWRzkauPMot26J0OZZdA==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
]
},
"node_modules/lefthook-freebsd-x64": {
"version": "1.13.5",
"resolved": "https://registry.npmjs.org/lefthook-freebsd-x64/-/lefthook-freebsd-x64-1.13.5.tgz",
"integrity": "sha512-6czek8XagVrI7ExURawkfrfX40Qjc/wktc8bLq/iXfRlmdvKDMrx2FrA82mDfEVCAEz+tTvkteK1TfR3icYF3Q==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
]
},
"node_modules/lefthook-linux-arm64": {
"version": "1.13.5",
"resolved": "https://registry.npmjs.org/lefthook-linux-arm64/-/lefthook-linux-arm64-1.13.5.tgz",
"integrity": "sha512-MjWtiuW1br+rpTtgG1KGV53mSGtL5MWQwgafYzrFleJ89fKb86F4TD/4mVNzk5thmZ+HVPZw9bRZGUHFBnNJWg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/lefthook-linux-x64": { "node_modules/lefthook-linux-x64": {
"version": "1.13.5", "version": "1.13.5",
"cpu": [ "cpu": [
@@ -2684,6 +2880,62 @@
"linux" "linux"
] ]
}, },
"node_modules/lefthook-openbsd-arm64": {
"version": "1.13.5",
"resolved": "https://registry.npmjs.org/lefthook-openbsd-arm64/-/lefthook-openbsd-arm64-1.13.5.tgz",
"integrity": "sha512-lYXrWf0/hBrwtG8ceaHq886bcqRKh3Lfv+jZJs+ykMLB6L/kaqk8tA4V2NHWydQ5h56o45ugs/580nMz36ZdRg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openbsd"
]
},
"node_modules/lefthook-openbsd-x64": {
"version": "1.13.5",
"resolved": "https://registry.npmjs.org/lefthook-openbsd-x64/-/lefthook-openbsd-x64-1.13.5.tgz",
"integrity": "sha512-Ba1JrsRbfan4WKd8Q7gUhTxCUuppXzirDObd3JxpLRSLxA47yxhjMv7KByDunRDTvzTgsXoykZI6mPupkc1JiQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openbsd"
]
},
"node_modules/lefthook-windows-arm64": {
"version": "1.13.5",
"resolved": "https://registry.npmjs.org/lefthook-windows-arm64/-/lefthook-windows-arm64-1.13.5.tgz",
"integrity": "sha512-Y/CpmEIb0hlFe+kTT/efWgX6+/gUTp5NItTF+gmUrY1/G/bTLIxdIRS7WpodVM0MEN24sOrQVTSi9DN9FvGoGg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/lefthook-windows-x64": {
"version": "1.13.5",
"resolved": "https://registry.npmjs.org/lefthook-windows-x64/-/lefthook-windows-x64-1.13.5.tgz",
"integrity": "sha512-WJBqGNBlFJnunRwy12QyaDHdGULtostPqpYSZSS4boFJDY0lP5qtz9lAGmJ49aA5GQ19jrnDjGLwVPFiwIqksQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/lilconfig": { "node_modules/lilconfig": {
"version": "3.1.3", "version": "3.1.3",
"dev": true, "dev": true,
@@ -2784,10 +3036,12 @@
} }
}, },
"node_modules/lucide-react": { "node_modules/lucide-react": {
"version": "0.468.0", "version": "0.552.0",
"resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.552.0.tgz",
"integrity": "sha512-g9WCjmfwqbexSnZE+2cl21PCfXOcqnGeWeMTNAOGEfpPbm/ZF4YIq77Z8qWrxbu660EKuLB4nSLggoKnCb+isw==",
"license": "ISC", "license": "ISC",
"peerDependencies": { "peerDependencies": {
"react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc" "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0"
} }
}, },
"node_modules/luxon": { "node_modules/luxon": {
@@ -3296,6 +3550,7 @@
} }
], ],
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"nanoid": "^3.3.11", "nanoid": "^3.3.11",
"picocolors": "^1.1.1", "picocolors": "^1.1.1",
@@ -3425,6 +3680,7 @@
"devOptional": true, "devOptional": true,
"hasInstallScript": true, "hasInstallScript": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"peer": true,
"dependencies": { "dependencies": {
"@prisma/config": "6.16.2", "@prisma/config": "6.16.2",
"@prisma/engines": "6.16.2" "@prisma/engines": "6.16.2"
@@ -3614,6 +3870,7 @@
"node_modules/react": { "node_modules/react": {
"version": "18.3.1", "version": "18.3.1",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"loose-envify": "^1.1.0" "loose-envify": "^1.1.0"
}, },
@@ -3632,6 +3889,7 @@
"node_modules/react-dom": { "node_modules/react-dom": {
"version": "18.3.1", "version": "18.3.1",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"loose-envify": "^1.1.0", "loose-envify": "^1.1.0",
"scheduler": "^0.23.2" "scheduler": "^0.23.2"
@@ -4349,6 +4607,7 @@
"version": "4.0.3", "version": "4.0.3",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=12" "node": ">=12"
}, },
@@ -4501,6 +4760,7 @@
"version": "7.1.7", "version": "7.1.7",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"esbuild": "^0.25.0", "esbuild": "^0.25.0",
"fdir": "^6.5.0", "fdir": "^6.5.0",
@@ -4590,6 +4850,7 @@
"version": "4.0.3", "version": "4.0.3",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": ">=12" "node": ">=12"
}, },

View File

@@ -1797,7 +1797,12 @@ create_agent_version() {
cp "$APP_DIR/agents/patchmon-agent.sh" "$APP_DIR/backend/" cp "$APP_DIR/agents/patchmon-agent.sh" "$APP_DIR/backend/"
print_status "Agent version management removed - using file-based approach" print_status "Agent version management removed - using file-based approach"
# Ensure we close the conditional and the function properly fi
# Make agent binaries executable
if [ -d "$APP_DIR/agents" ]; then
chmod +x "$APP_DIR/agents/patchmon-agent-linux-"* 2>/dev/null || true
print_status "Agent binaries made executable"
fi fi
return 0 return 0
@@ -2703,6 +2708,13 @@ update_env_file() {
: ${TFA_MAX_REMEMBER_SESSIONS:=5} : ${TFA_MAX_REMEMBER_SESSIONS:=5}
: ${TFA_SUSPICIOUS_ACTIVITY_THRESHOLD:=3} : ${TFA_SUSPICIOUS_ACTIVITY_THRESHOLD:=3}
# Prisma Connection Pool
: ${DB_CONNECTION_LIMIT:=30}
: ${DB_POOL_TIMEOUT:=20}
: ${DB_CONNECT_TIMEOUT:=10}
: ${DB_IDLE_TIMEOUT:=300}
: ${DB_MAX_LIFETIME:=1800}
# Track which variables were added # Track which variables were added
local added_vars=() local added_vars=()
@@ -2764,6 +2776,21 @@ update_env_file() {
if ! grep -q "^TFA_SUSPICIOUS_ACTIVITY_THRESHOLD=" "$env_file"; then if ! grep -q "^TFA_SUSPICIOUS_ACTIVITY_THRESHOLD=" "$env_file"; then
added_vars+=("TFA_SUSPICIOUS_ACTIVITY_THRESHOLD") added_vars+=("TFA_SUSPICIOUS_ACTIVITY_THRESHOLD")
fi fi
if ! grep -q "^DB_CONNECTION_LIMIT=" "$env_file"; then
added_vars+=("DB_CONNECTION_LIMIT")
fi
if ! grep -q "^DB_POOL_TIMEOUT=" "$env_file"; then
added_vars+=("DB_POOL_TIMEOUT")
fi
if ! grep -q "^DB_CONNECT_TIMEOUT=" "$env_file"; then
added_vars+=("DB_CONNECT_TIMEOUT")
fi
if ! grep -q "^DB_IDLE_TIMEOUT=" "$env_file"; then
added_vars+=("DB_IDLE_TIMEOUT")
fi
if ! grep -q "^DB_MAX_LIFETIME=" "$env_file"; then
added_vars+=("DB_MAX_LIFETIME")
fi
# If there are missing variables, add them # If there are missing variables, add them
if [ ${#added_vars[@]} -gt 0 ]; then if [ ${#added_vars[@]} -gt 0 ]; then
@@ -2849,6 +2876,25 @@ EOF
echo "TFA_SUSPICIOUS_ACTIVITY_THRESHOLD=$TFA_SUSPICIOUS_ACTIVITY_THRESHOLD" >> "$env_file" echo "TFA_SUSPICIOUS_ACTIVITY_THRESHOLD=$TFA_SUSPICIOUS_ACTIVITY_THRESHOLD" >> "$env_file"
fi fi
# Add Prisma connection pool config if missing
if printf '%s\n' "${added_vars[@]}" | grep -q "DB_CONNECTION_LIMIT"; then
echo "" >> "$env_file"
echo "# Database Connection Pool Configuration (Prisma)" >> "$env_file"
echo "DB_CONNECTION_LIMIT=$DB_CONNECTION_LIMIT" >> "$env_file"
fi
if printf '%s\n' "${added_vars[@]}" | grep -q "DB_POOL_TIMEOUT"; then
echo "DB_POOL_TIMEOUT=$DB_POOL_TIMEOUT" >> "$env_file"
fi
if printf '%s\n' "${added_vars[@]}" | grep -q "DB_CONNECT_TIMEOUT"; then
echo "DB_CONNECT_TIMEOUT=$DB_CONNECT_TIMEOUT" >> "$env_file"
fi
if printf '%s\n' "${added_vars[@]}" | grep -q "DB_IDLE_TIMEOUT"; then
echo "DB_IDLE_TIMEOUT=$DB_IDLE_TIMEOUT" >> "$env_file"
fi
if printf '%s\n' "${added_vars[@]}" | grep -q "DB_MAX_LIFETIME"; then
echo "DB_MAX_LIFETIME=$DB_MAX_LIFETIME" >> "$env_file"
fi
print_status ".env file updated with ${#added_vars[@]} new variable(s)" print_status ".env file updated with ${#added_vars[@]} new variable(s)"
print_info "Added variables: ${added_vars[*]}" print_info "Added variables: ${added_vars[*]}"
else else
@@ -2918,11 +2964,37 @@ update_installation() {
print_info "Installation directory: $instance_dir" print_info "Installation directory: $instance_dir"
print_info "Service name: $service_name" print_info "Service name: $service_name"
# Verify it's a git repository # Verify it's a git repository, if not, initialize it
if [ ! -d "$instance_dir/.git" ]; then if [ ! -d "$instance_dir/.git" ]; then
print_error "Installation directory is not a git repository" print_warning "Installation directory is not a git repository"
print_error "Cannot perform git-based update" print_info "Attempting to re-initialize as git repository..."
exit 1
cd "$instance_dir" || exit 1
# Initialize git repository
git init
git remote add origin https://github.com/PatchMon/PatchMon.git
# Fetch all branches
git fetch origin
# Try to determine current version from package.json or default to main
local current_branch="main"
if [ -f "$instance_dir/backend/package.json" ]; then
local pkg_version=$(grep '"version"' "$instance_dir/backend/package.json" | head -1 | sed 's/.*"version": "\(.*\)".*/\1/')
if [ -n "$pkg_version" ]; then
# Check if there's a release branch for this version
if git ls-remote --heads origin | grep -q "release/$(echo $pkg_version | sed 's/\./-/g')"; then
current_branch="release/$(echo $pkg_version | sed 's/\./-/g')"
fi
fi
fi
# Reset to the determined branch
git reset --hard "origin/$current_branch"
git checkout -B "$current_branch" "origin/$current_branch"
print_success "Repository initialized successfully"
fi fi
# Add git safe.directory to avoid ownership issues when running as root # Add git safe.directory to avoid ownership issues when running as root
@@ -3028,6 +3100,12 @@ update_installation() {
print_info "Building frontend..." print_info "Building frontend..."
npm run build npm run build
# Make agent binaries executable
if [ -d "$instance_dir/agents" ]; then
chmod +x "$instance_dir/agents/patchmon-agent-linux-"* 2>/dev/null || true
print_status "Agent binaries made executable"
fi
# Run database migrations with self-healing # Run database migrations with self-healing
print_info "Running database migrations..." print_info "Running database migrations..."
cd "$instance_dir/backend" cd "$instance_dir/backend"