File tree 1 file changed +22
-20
lines changed
1 file changed +22
-20
lines changed Original file line number Diff line number Diff line change @@ -21,26 +21,28 @@ export class Heart {
21
21
* activity. Failures are logged as warnings.
22
22
*/
23
23
public beat ( ) : void {
24
- if ( ! this . alive ( ) ) {
25
- logger . trace ( "heartbeat" )
26
- fs . writeFile ( this . heartbeatPath , "" ) . catch ( ( error ) => {
27
- logger . warn ( error . message )
28
- } )
29
- this . lastHeartbeat = Date . now ( )
30
- if ( typeof this . heartbeatTimer !== "undefined" ) {
31
- clearTimeout ( this . heartbeatTimer )
32
- }
33
- this . heartbeatTimer = setTimeout ( ( ) => {
34
- this . isActive ( )
35
- . then ( ( active ) => {
36
- if ( active ) {
37
- this . beat ( )
38
- }
39
- } )
40
- . catch ( ( error ) => {
41
- logger . warn ( error . message )
42
- } )
43
- } , this . heartbeatInterval )
24
+ if ( this . alive ( ) ) {
25
+ return
44
26
}
27
+
28
+ logger . trace ( "heartbeat" )
29
+ fs . writeFile ( this . heartbeatPath , "" ) . catch ( ( error ) => {
30
+ logger . warn ( error . message )
31
+ } )
32
+ this . lastHeartbeat = Date . now ( )
33
+ if ( typeof this . heartbeatTimer !== "undefined" ) {
34
+ clearTimeout ( this . heartbeatTimer )
35
+ }
36
+ this . heartbeatTimer = setTimeout ( ( ) => {
37
+ this . isActive ( )
38
+ . then ( ( active ) => {
39
+ if ( active ) {
40
+ this . beat ( )
41
+ }
42
+ } )
43
+ . catch ( ( error ) => {
44
+ logger . warn ( error . message )
45
+ } )
46
+ } , this . heartbeatInterval )
45
47
}
46
48
}
You can’t perform that action at this time.
0 commit comments