feat(database): configure local to use central database directly and disable local mongo

This commit is contained in:
rafif committed 2026-08-24 14:33:51 +07:00
1 parent d7561dc85d
commit f1c1ba03b5
24 files changed
+1135 -336

No files matched your search

+3 -3
View File
@@ -111,7 +111,7 @@ const POST_DEPLOY_COMMANDS = [
// Copy Next.js static assets to standalone directory (required for standalone mode)
// Fix standalone directory structure for Next.js
'mkdir -p /home/adminbackend/web/demoplace.my.id/public_html/.next/standalone/.next/',
'cp -r /home/adminbackend/web/demoplace.my.id/public_html/.next/static /home/adminbackend/web/demoplace.my.id/public_html/.next/standalone/.next/static && echo "Static assets copied to standalone"',
'rm -rf /home/adminbackend/web/demoplace.my.id/public_html/.next/standalone/.next/static && cp -r /home/adminbackend/web/demoplace.my.id/public_html/.next/static /home/adminbackend/web/demoplace.my.id/public_html/.next/standalone/.next/static && echo "Static assets copied to standalone"',
'cp -r /home/adminbackend/web/demoplace.my.id/public_html/public /home/adminbackend/web/demoplace.my.id/public_html/.next/standalone/public 2>/dev/null || true',
'ln -sfn /home/adminbackend/web/demoplace.my.id/public_html/.next/standalone/.next /home/adminbackend/web/demoplace.my.id/public_html/_next',
'ln -sfn /home/adminbackend/web/demoplace.my.id/public_html/.next/standalone/.next/static /home/adminbackend/web/demoplace.my.id/public_html/.next/static',
@@ -239,7 +239,7 @@ function runSshCommands(commands) {
port: CONFIG.port,
username: CONFIG.username,
password: CONFIG.password,
readyTimeout: 30000,
readyTimeout: 90000,
});
});
}
@@ -280,7 +280,7 @@ async function deploy() {
port: CONFIG.port,
username: CONFIG.username,
password: CONFIG.password,
readyTimeout: 30000,
readyTimeout: 90000,
});
console.log('[SFTP] Connected!\n');
+55
View File
@@ -0,0 +1,55 @@
// scripts/diagnose-labeling-bug.js
const { Client } = require('ssh2');
const CONFIG = {
host: '103.185.47.52',
port: 2222,
username: 'adminbackend',
password: 'htEo7x6LsBQiEHHH',
};
function execCmd(ssh, cmd) {
return new Promise((resolve) => {
console.log(`\n========================================`);
console.log(`EXEC: ${cmd}`);
console.log(`========================================`);
ssh.exec(cmd, (err, stream) => {
if (err) {
console.error('Exec error:', err.message);
return resolve('');
}
let out = '';
stream.on('data', (d) => { out += d; process.stdout.write(d); });
stream.stderr.on('data', (d) => { out += d; process.stderr.write(d); });
stream.on('close', () => resolve(out));
});
});
}
async function main() {
const ssh = new Client();
ssh.on('ready', async () => {
console.log('[SSH] Connected for targetted diagnosis...');
const pm2Path = '/home/adminbackend/.npm-global/bin/pm2';
// 1. List PM2 processes
await execCmd(ssh, `${pm2Path} list`);
// 2. Fetch last 50 error logs of frontend
await execCmd(ssh, `${pm2Path} logs backone-frontend --lines 50 --err --raw`);
// 3. Fetch last 50 output logs of frontend
await execCmd(ssh, `${pm2Path} logs backone-frontend --lines 50 --out --raw`);
// 4. Check pm2 logs backone-backend or other backend services
await execCmd(ssh, `${pm2Path} logs backone-backend --lines 50 --err --raw`);
// 5. Check if the directory next standalone actually contains device-labeling folder
await execCmd(ssh, `find /home/adminbackend/web/demoplace.my.id/public_html/.next/standalone/.next/server/app -name "device-labeling" || echo "Not found"`);
await execCmd(ssh, `ls -la /home/adminbackend/web/demoplace.my.id/public_html/.next/standalone/.next/server/app/ || echo "Failed to list app dir"`);
ssh.end();
}).connect({ host: CONFIG.host, port: CONFIG.port, username: CONFIG.username, password: CONFIG.password });
}
main().catch(console.error);
+18 -1
View File
@@ -10,6 +10,19 @@ const CONFIG = {
const cleanProxyPhpCode = `<?php
// proxy.php — Reverse proxy to BackOne Dashboard Engine on port 3000
if (!function_exists('getallheaders')) {
function getallheaders() {
$headers = array();
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
return $headers;
}
}
$target = 'http://127.0.0.1:3000' . $_SERVER['REQUEST_URI'];
$ch = curl_init($target);
@@ -50,7 +63,11 @@ curl_close($ch);
http_response_code($status);
foreach (explode("\r\n", $resp_headers) as $h) {
if ($h && !str_starts_with($h, 'HTTP/') && !str_starts_with(strtolower($h), 'transfer-encoding:')) {
if ($h && stripos($h, 'HTTP/') !== 0 && stripos($h, 'transfer-encoding:') !== 0) {
if (stripos($h, 'location:') === 0) {
$h = str_replace('http://127.0.0.1:3000', '', $h);
$h = str_replace('http://localhost:3000', '', $h);
}
header($h, false);
}
}