File tree Expand file tree Collapse file tree 3 files changed +39
-34
lines changed Expand file tree Collapse file tree 3 files changed +39
-34
lines changed Original file line number Diff line number Diff line change @@ -16,17 +16,18 @@ async function loadOptions() {
16
16
}
17
17
18
18
async function run ( ) {
19
- try {
20
- log . info ( '[options] Start options refresh' ) ;
21
- await loadOptions ( ) ;
22
- log . info ( `[options] ${ options . length } options reloaded` ) ;
23
- log . info ( '[options] End options refresh' ) ;
24
- } catch ( e : any ) {
25
- capture ( e ) ;
26
- log . error ( `[options] failed to refresh options, ${ JSON . stringify ( e ) } ` ) ;
19
+ while ( true ) {
20
+ try {
21
+ log . info ( '[options] Start options refresh' ) ;
22
+ await loadOptions ( ) ;
23
+ log . info ( `[options] ${ options . length } options reloaded` ) ;
24
+ log . info ( '[options] End options refresh' ) ;
25
+ } catch ( e : any ) {
26
+ capture ( e ) ;
27
+ log . error ( `[options] failed to refresh options, ${ JSON . stringify ( e ) } ` ) ;
28
+ }
29
+ await snapshot . utils . sleep ( RUN_INTERVAL ) ;
27
30
}
28
- await snapshot . utils . sleep ( RUN_INTERVAL ) ;
29
- run ( ) ;
30
31
}
31
32
32
33
run ( ) ;
Original file line number Diff line number Diff line change @@ -323,19 +323,19 @@ export async function getSpace(id: string) {
323
323
}
324
324
325
325
export default async function run ( ) {
326
- try {
327
- log . info ( '[spaces] Start spaces refresh' ) ;
328
-
329
- await loadSpaces ( ) ;
330
- await loadSpacesMetrics ( ) ;
331
-
332
- sortSpaces ( ) ;
333
- log . info ( '[spaces] End spaces refresh' ) ;
334
- } catch ( e : any ) {
335
- capture ( e ) ;
336
- log . error ( `[spaces] failed to load spaces, ${ JSON . stringify ( e ) } ` ) ;
326
+ while ( true ) {
327
+ try {
328
+ log . info ( '[spaces] Start spaces refresh' ) ;
329
+
330
+ await loadSpaces ( ) ;
331
+ await loadSpacesMetrics ( ) ;
332
+
333
+ sortSpaces ( ) ;
334
+ log . info ( '[spaces] End spaces refresh' ) ;
335
+ } catch ( e : any ) {
336
+ capture ( e ) ;
337
+ log . error ( `[spaces] failed to load spaces, ${ JSON . stringify ( e ) } ` ) ;
338
+ }
339
+ await snapshot . utils . sleep ( RUN_INTERVAL ) ;
337
340
}
338
- await snapshot . utils . sleep ( RUN_INTERVAL ) ;
339
-
340
- run ( ) ;
341
341
}
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { spaces } from './spaces';
7
7
export let strategies : any [ ] = [ ] ;
8
8
export let strategiesObj : any = { } ;
9
9
10
+ const RUN_INTERVAL = 60e3 ;
10
11
const scoreApiURL : URL = new URL (
11
12
process . env . SCORE_API_URL ?? 'https://score.snapshot.org'
12
13
) ;
@@ -56,19 +57,22 @@ async function loadStrategies() {
56
57
}
57
58
58
59
async function run ( ) {
59
- try {
60
- await loadStrategies ( ) ;
61
- consecutiveFailsCount = 0 ;
62
- } catch ( e : any ) {
63
- consecutiveFailsCount ++ ;
60
+ while ( true ) {
61
+ try {
62
+ log . info ( '[strategies] Start strategies refresh' ) ;
63
+ await loadStrategies ( ) ;
64
+ consecutiveFailsCount = 0 ;
65
+ log . info ( '[strategies] End strategies refresh' ) ;
66
+ } catch ( e : any ) {
67
+ consecutiveFailsCount ++ ;
64
68
65
- if ( consecutiveFailsCount >= 3 ) {
66
- capture ( e ) ;
69
+ if ( consecutiveFailsCount >= 3 ) {
70
+ capture ( e ) ;
71
+ }
72
+ log . error ( `[strategies] failed to load ${ JSON . stringify ( e ) } ` ) ;
67
73
}
68
- log . error ( `[strategies] failed to load ${ JSON . stringify ( e ) } ` ) ;
74
+ await snapshot . utils . sleep ( RUN_INTERVAL ) ;
69
75
}
70
- await snapshot . utils . sleep ( 60e3 ) ;
71
- run ( ) ;
72
76
}
73
77
74
78
run ( ) ;
You can’t perform that action at this time.
0 commit comments