Commit 08c7f4069cdce828fca342efbc542b6d667c6b7c

Authored by Adhidarma Hadiwinoto
1 parent 770e57599f
Exists in master

Log on exception at fileCountOnDir

Showing 1 changed file with 4 additions and 0 deletions Inline Diff

lib/smstools-util.js
1 const fs = require('fs'); 1 const fs = require('fs');
2 const childProcess = require('child_process'); 2 const childProcess = require('child_process');
3 const config = require('komodo-sdk/config'); 3 const config = require('komodo-sdk/config');
4 const logger = require('komodo-sdk/logger');
4 5
5 exports.restart = () => new Promise((resolve) => { 6 exports.restart = () => new Promise((resolve) => {
6 const fileToExec = config.restart_smstools_wrapper || '/var/lib/smstools/centers/smstools/bin/restart-smstools'; 7 const fileToExec = config.restart_smstools_wrapper || '/var/lib/smstools/centers/smstools/bin/restart-smstools';
7 childProcess.execFile(fileToExec, (err, stdout, stderr) => { 8 childProcess.execFile(fileToExec, (err, stdout, stderr) => {
8 resolve({ 9 resolve({
9 err, 10 err,
10 stdout, 11 stdout,
11 stderr, 12 stderr,
12 }); 13 });
13 }); 14 });
14 }); 15 });
15 16
16 exports.fileCountOnDir = async (dirname) => { 17 exports.fileCountOnDir = async (dirname) => {
17 try { 18 try {
18 const files = fs.promises.readdir(dirname); 19 const files = fs.promises.readdir(dirname);
19 return files.filter((item) => item.search(/LOCK$/) >= 0).length; 20 return files.filter((item) => item.search(/LOCK$/) >= 0).length;
20 } catch (e) { 21 } catch (e) {
22 logger.warn('SMSTOOLS-UTIL: Exception on fileCountOnDir', {
23 e: e.message || e.toString(),
24 });
21 return null; 25 return null;
22 } 26 }
23 }; 27 };
24 28