From 9198e9baa333a3419a8b10547d3e9ae1ddbaec43 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Sun, 24 Nov 2024 05:47:50 +0700 Subject: [PATCH] Add subdomain --- package-lock.json | 4 ++-- package.json | 2 +- src/controllers/logman.js | 3 ++- src/executor/logman.js | 13 +++++++++---- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 24c95b4..26e9aec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "domcloud-bridge", - "version": "1.0.241123", + "version": "1.0.241124", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "domcloud-bridge", - "version": "1.0.241123", + "version": "1.0.241124", "license": "MIT", "dependencies": { "cli": "^1.0.1", diff --git a/package.json b/package.json index 95b7488..054fa35 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "domcloud-bridge", - "version": "1.0.241123", + "version": "1.0.241124", "description": "Deployment runner for DOM Cloud", "main": "app.js", "engines": { diff --git a/src/controllers/logman.js b/src/controllers/logman.js index 8381935..9582689 100644 --- a/src/controllers/logman.js +++ b/src/controllers/logman.js @@ -10,8 +10,9 @@ export default function () { try { let type = req.query.type.toString() let user = req.query.user.toString() + let sub = req.query.sub.toString() let n = parseInt((req.query.n || 100).toString()) || 100; - let output = await logmanExec.getLog(user, type, n); + let output = await logmanExec.getLog(user, type, sub, n); return res.json(output); } catch (err) { next(err); diff --git a/src/executor/logman.js b/src/executor/logman.js index 5058d77..0d067c6 100644 --- a/src/executor/logman.js +++ b/src/executor/logman.js @@ -17,19 +17,24 @@ class LogmanExecutor { /** * @param {string} user * @param {string} type + * @param {string} sub * @param {number} n */ - async getLog(user, type, n) { + async getLog(user, type, sub, n) { + let home = `/home/${user}`; + if (sub) { + home += `/domains/${sub}` + } switch (type) { case 'access': return await spawnSudoUtil("SHELL_SUDO", ["root", - "tail", "-n", n + '', `/home/${user}/logs/access_log`]); + "tail", "-n", n + '', `${home}/logs/access_log`]); case 'error': return await spawnSudoUtil("SHELL_SUDO", ["root", - "tail", "-n", n + '', `/home/${user}/logs/error_log`]); + "tail", "-n", n + '', `${home}/logs/error_log`]); case 'php': return await spawnSudoUtil("SHELL_SUDO", ["root", - "tail", "-n", n + '', `/home/${user}/logs/php_log`]); + "tail", "-n", n + '', `${home}/logs/php_log`]); case 'proxfix': return await spawnSudoUtil("SHELL_SUDO", ["root", "tail", "-n", n + '', `/home/${user}/tmp/app.log`]);