File tree 1 file changed +19
-6
lines changed
1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,15 @@ const filterAsync = async <T>(
156
156
157
157
const delay = ( ms ) => new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
158
158
159
+ const sendHeartbeat = async ( ) => {
160
+ if ( HEARTBEAT_URL ) {
161
+ logger . debug ( "Sending heartbeat" ) ;
162
+ fetch ( HEARTBEAT_URL ) ;
163
+ } else {
164
+ logger . debug ( "Heartbeat not set up, skipping" ) ;
165
+ }
166
+ } ;
167
+
159
168
async function main ( ) {
160
169
const { core, sortition, disputeKitClassic } = await getContracts ( ) ;
161
170
@@ -193,6 +202,8 @@ async function main() {
193
202
return ( await sortition . phase ( ) ) === 2 ;
194
203
} ;
195
204
205
+ await sendHeartbeat ( ) ;
206
+
196
207
// get all the non-final disputes
197
208
const nonFinalDisputesRequest = `{
198
209
disputes(where: {period_not: execution}) {
@@ -270,6 +281,8 @@ async function main() {
270
281
}
271
282
}
272
283
284
+ await sendHeartbeat ( ) ;
285
+
273
286
for ( dispute of disputes ) {
274
287
await passPeriod ( dispute ) ;
275
288
@@ -315,17 +328,17 @@ async function main() {
315
328
}
316
329
}
317
330
318
- if ( HEARTBEAT_URL ) {
319
- logger . debug ( "Sending heartbeat" ) ;
320
- fetch ( HEARTBEAT_URL ) ;
321
- } else {
322
- logger . debug ( "Heartbeat not set up, skipping" ) ;
323
- }
331
+ await sendHeartbeat ( ) ;
332
+
333
+ await delay ( 2000 ) ; // Some log messages may be lost otherwise
324
334
}
325
335
326
336
main ( )
327
337
. then ( ( ) => process . exit ( 0 ) )
328
338
. catch ( ( error ) => {
329
339
console . error ( error ) ;
330
340
process . exit ( 1 ) ;
341
+ } )
342
+ . finally ( ( ) => {
343
+ logger . flush ( ) ;
331
344
} ) ;
You can’t perform that action at this time.
0 commit comments