fix: salva arquivo .installed no volume data persistente para evitar reinicio de instalacao apos reset do container
continuous-integration/webhook Deploy concluido (rx.scoreodonto.com)
continuous-integration/webhook Deploy concluido (rx.scoreodonto.com)
This commit is contained in:
@@ -3,7 +3,7 @@ const path = require('path');
|
||||
const db = require('../database');
|
||||
|
||||
async function checkInstallation() {
|
||||
const installedFile = fs.existsSync(path.join(__dirname, '..', '.installed'));
|
||||
const installedFile = fs.existsSync(path.join(__dirname, '..', 'data', '.installed'));
|
||||
let currentVersion = '1.0.0';
|
||||
let databaseExists = false;
|
||||
let userExists = false;
|
||||
|
||||
@@ -349,7 +349,7 @@ app.post('/api/install', async (req, res) => {
|
||||
console.log('✅ Usuário admin criado:', admin.username);
|
||||
|
||||
// Criar arquivo .installed
|
||||
const installedPath = path.join(__dirname, '.installed');
|
||||
const installedPath = path.join(__dirname, 'data', '.installed');
|
||||
await fs.writeFile(installedPath, new Date().toISOString());
|
||||
|
||||
// Criar arquivo version.txt
|
||||
@@ -505,7 +505,8 @@ async function checkInstallationMiddleware(req, res, next) {
|
||||
// Para APIs que não são de instalação ou auth, verificar instalação
|
||||
if (isApiRoute) {
|
||||
try {
|
||||
const installedFile = path.join(__dirname, '.installed');
|
||||
// Procura no diretório persistente de dados
|
||||
const installedFile = path.join(__dirname, 'data', '.installed');
|
||||
const fsSync = require('fs');
|
||||
|
||||
if (!fsSync.existsSync(installedFile)) {
|
||||
@@ -522,7 +523,7 @@ async function checkInstallationMiddleware(req, res, next) {
|
||||
// Se não for API e não for rota pública liberada acima, e estiver sem .installed,
|
||||
// manda pro install.
|
||||
try {
|
||||
const installedFile = path.join(__dirname, '.installed');
|
||||
const installedFile = path.join(__dirname, 'data', '.installed');
|
||||
const fsSync = require('fs');
|
||||
if (!fsSync.existsSync(installedFile)) {
|
||||
return res.redirect('/install');
|
||||
@@ -1003,7 +1004,7 @@ async function start() {
|
||||
console.log(`🖼️ Processed at: ${PROCESSED_DIR}`);
|
||||
console.log('═══════════════════════════════════════════════════════');
|
||||
|
||||
const installedFile = path.join(__dirname, '.installed');
|
||||
const installedFile = path.join(__dirname, 'data', '.installed');
|
||||
if (!fsSync.existsSync(installedFile)) {
|
||||
console.log('⚠️ Sistema não instalado. Acesse /install para configurar.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user