- AbitaregliIblei.it

- Server aggiornamenti agli script.
- Editor HTML corretto un po'.
- Record Mysql per server (appena iniziato)
This commit is contained in:
Surya Paolo
2024-09-06 19:57:09 +02:00
parent 45f601bd26
commit fe4a67c9f1
28 changed files with 638 additions and 567 deletions

View File

@@ -1861,9 +1861,9 @@ module.exports = {
this.MYAPPS.find(item => item.idapp === idapp);
if (myapp) {
if (process.env.NODE_ENV === 'test')
mypath = (myapp) ? myapp.dir_test : '';
mypath = (myapp && myapp.dir_test) ? myapp.dir_test : '';
else
mypath = (myapp) ? myapp.dir : '';
mypath = (myapp && myapp.dir) ? myapp.dir : '';
if (dirmain) {
if (!this.sulServer()) {
@@ -3812,15 +3812,30 @@ module.exports = {
},
readlogfile(idapp, filename) {
async readlogfile(idapp, filename) {
try {
return fs.readFileSync(idapp + '/' + filename, 'utf8');
return await fs.readFileSync(idapp + '/' + filename, 'utf8');
} catch (e) {
return '';
}
},
async readfilecontent(filename) {
try {
const cont = await fs.readFileSync(filename, 'utf8');
return cont;
} catch (e) {
return '';
}
},
async getVersServer() {
return await this.readfilecontent(__dirname + '/../version.txt');
},
writelog(mystr) {
this.writelogfile(mystr, FILELOG);
},
@@ -3852,11 +3867,6 @@ module.exports = {
this.writelogfile(mystr, idapp + '/' + riga + '_' + col + '.txt');
},
readFlottaLog(idapp, riga, col) {
const nomefile = riga + '_' + col + '.txt';
return this.readlogfile(idapp, nomefile);
},
writeNaveLog(mystr) {
this.writelogfile(mystr, FILENAVE);
},
@@ -4507,6 +4517,7 @@ module.exports = {
for (let i = 0; i < arrscripts.length; i++) {
let label = arrscripts[i];
let sock = false;
let description = '';
if (listafiles) {
if (arrscripts[i].endsWith('.sh')) {
@@ -4537,6 +4548,8 @@ module.exports = {
label = value;
} else if (paramstr === 'DESCRIZ') {
description = value;
} else if (paramstr === 'SOCK') {
sock = (value.toLowerCase() === 'true');
}
}
@@ -4551,7 +4564,7 @@ module.exports = {
}
if ((label) && (!extfiles || (extfiles && arrscripts[i].endsWith('.' + extfiles)))) {
arrout.push({ label, value: arrscripts[i], description });
arrout.push({ label, value: arrscripts[i], description, sock });
}
}
@@ -4559,6 +4572,20 @@ module.exports = {
});
});
},
execScriptNoOutput: async function (script) {
return new Promise(async (resolve, reject) => {
console.log('execScriptNoOutput:', script);
exec(script, async (error, stdout, stderr) => { // Aggiunto async qui
if (error) {
console.error(`error: ${error}`);
}
if (stderr) {
console.error(`stderr: ${stderr}`);
}
resolve(!error && !stderr);
});
});
},
execScriptWithInputOnServer: async function (idapp, script) {
return new Promise((resolve, reject) => {