File tree 1 file changed +14
-6
lines changed
1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -53,11 +53,11 @@ class WindowsSystemMonitor {
53
53
}
54
54
55
55
async function main ( ) {
56
- console . log ( ' Starting WhatsApp service...' )
56
+ console . log ( " Starting WhatsApp service..." ) ;
57
57
const whatsAppService = new WhatsAppService ( ) ;
58
58
await whatsAppService . ready ( ) ;
59
59
60
- schedule . scheduleJob ( config . schedule , ( ) => {
60
+ function monitorService ( ) {
61
61
WindowsSystemMonitor . checkPythonService ( ( err , stdout , stderr ) => {
62
62
if ( err ) {
63
63
console . error ( "Error:" , err ) ;
@@ -70,13 +70,21 @@ async function main() {
70
70
}
71
71
72
72
if ( ! stdout . includes ( config . serviceName ) ) {
73
- console . log ( 'Service is not running' ) ;
74
- whatsAppService . sendMessage ( config . chatId , config . serviceName + " is not running, please check!" ) ;
73
+ console . log ( "Service is not running" ) ;
74
+ whatsAppService . sendMessage (
75
+ config . chatId ,
76
+ config . serviceName + " is not running, please check!"
77
+ ) ;
78
+ console . log ( "Message sent to " + config . chatId ) ;
75
79
} else {
76
- console . log ( ' Service is running' ) ;
80
+ console . log ( " Service is running" ) ;
77
81
}
78
82
} ) ;
79
- } ) ;
83
+ }
84
+
85
+ monitorService ( ) ;
86
+
87
+ schedule . scheduleJob ( config . schedule , monitorService ) ;
80
88
}
81
89
82
90
main ( ) ;
You can’t perform that action at this time.
0 commit comments