[STABLE] v0.4.2.2 - Critical stability fixes for production (Synology/NAS)
This commit is contained in:
parent
3aa442e0fa
commit
0efe144b09
@ -51,6 +51,9 @@ const sessionStoreOptions = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const sessionStore = new MySQLStore(sessionStoreOptions);
|
const sessionStore = new MySQLStore(sessionStoreOptions);
|
||||||
|
sessionStore.on('error', (err) => {
|
||||||
|
console.error('Session Store Error:', err);
|
||||||
|
});
|
||||||
|
|
||||||
// Middleware
|
// Middleware
|
||||||
app.use(cors({
|
app.use(cors({
|
||||||
@ -456,29 +459,13 @@ initTables();
|
|||||||
const packageJson = require('./package.json');
|
const packageJson = require('./package.json');
|
||||||
|
|
||||||
app.get('/api/health', (req, res) => {
|
app.get('/api/health', (req, res) => {
|
||||||
// Force Korean time (UTC+9) for the timestamp
|
// Light-weight health check
|
||||||
const kstOffset = 9 * 60 * 60 * 1000;
|
const kstOffset = 9 * 60 * 60 * 1000;
|
||||||
const kstDate = new Date(Date.now() + kstOffset);
|
const kstDate = new Date(Date.now() + kstOffset);
|
||||||
|
|
||||||
// Dynamic Version detection: Prioritize local Git Tag to match the "Update" rule
|
|
||||||
let version = '0.0.0.0';
|
|
||||||
try {
|
|
||||||
const { execSync } = require('child_process');
|
|
||||||
// Get the latest tag on the current commit
|
|
||||||
version = execSync('git describe --tags --abbrev=0', { cwd: path.join(__dirname, '..') }).toString().trim().replace(/^v/, '');
|
|
||||||
} catch (e) {
|
|
||||||
// Fallback to root package.json if git fails
|
|
||||||
try {
|
|
||||||
const rootPkg = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8'));
|
|
||||||
version = rootPkg.version;
|
|
||||||
} catch (err) {
|
|
||||||
version = packageJson.version; // Fallback to server/package.json
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
status: 'ok',
|
status: 'ok',
|
||||||
version: version,
|
version: packageJson.version,
|
||||||
node_version: process.version,
|
node_version: process.version,
|
||||||
platform: process.platform,
|
platform: process.platform,
|
||||||
arch: process.arch,
|
arch: process.arch,
|
||||||
|
|||||||
@ -489,30 +489,24 @@ const getGiteaAuth = async () => {
|
|||||||
// 5. Get Version Info (Current, Remote & History from Tags)
|
// 5. Get Version Info (Current, Remote & History from Tags)
|
||||||
router.get('/version/remote', isAuthenticated, hasRole('admin'), async (req, res) => {
|
router.get('/version/remote', isAuthenticated, hasRole('admin'), async (req, res) => {
|
||||||
try {
|
try {
|
||||||
// Dynamic Version detection: Prioritize local Git Tag
|
// Local version detection (No caching)
|
||||||
let currentVersion = '0.0.0.0';
|
let currentVersion = '0.0.0.0';
|
||||||
try {
|
try {
|
||||||
currentVersion = execSync('git describe --tags --abbrev=0', { cwd: path.join(__dirname, '../..') }).toString().trim().replace(/^v/, '');
|
const rootPkg = JSON.parse(fs.readFileSync(path.join(__dirname, '../../package.json'), 'utf8'));
|
||||||
|
currentVersion = rootPkg.version;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
try {
|
currentVersion = '0.4.2.1';
|
||||||
const packageJsonPath = path.resolve(__dirname, '../../package.json');
|
|
||||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
||||||
currentVersion = packageJson.version;
|
|
||||||
} catch (err) {
|
|
||||||
currentVersion = '0.4.0.0'; // Ultimate fallback
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare git fetch command with auth if available
|
// Prepare git fetch command
|
||||||
const auth = await getGiteaAuth();
|
const auth = await getGiteaAuth();
|
||||||
let fetchCmd = 'git fetch --tags --force';
|
let fetchCmd = 'git fetch --tags';
|
||||||
|
|
||||||
if (auth.user && auth.pass) {
|
if (auth.user && auth.pass && auth.url && auth.url.includes('https://')) {
|
||||||
const authenticatedUrl = auth.url.replace('https://', `https://${encodeURIComponent(auth.user)}:${encodeURIComponent(auth.pass)}@`);
|
const authenticatedUrl = auth.url.replace('https://', `https://${encodeURIComponent(auth.user)}:${encodeURIComponent(auth.pass)}@`);
|
||||||
// Use explicit refspec to ensure local tags are updated from the remote URL
|
fetchCmd = `git fetch ${authenticatedUrl} --tags --force --prune`;
|
||||||
fetchCmd = `git fetch ${authenticatedUrl} +refs/tags/*:refs/tags/* --force --prune --prune-tags`;
|
} else if (auth.url) {
|
||||||
} else {
|
fetchCmd = `git fetch ${auth.url} --tags --force --prune`;
|
||||||
fetchCmd = `git fetch ${auth.url} +refs/tags/*:refs/tags/* --force --prune --prune-tags`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exec(fetchCmd, (err, stdout, stderr) => {
|
exec(fetchCmd, (err, stdout, stderr) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user