… | |
… | |
349 | my $runtime = cf::localdir . "/runtime"; |
349 | my $runtime = cf::localdir . "/runtime"; |
350 | |
350 | |
351 | my $fh = aio_open "$runtime~", O_WRONLY | O_CREAT, 0644 |
351 | my $fh = aio_open "$runtime~", O_WRONLY | O_CREAT, 0644 |
352 | or return; |
352 | or return; |
353 | |
353 | |
|
|
354 | my $value = $cf::RUNTIME + 90 + 10; |
354 | my $value = $cf::RUNTIME + 1 + 10; # 10 is the runtime save interval, for a monotonic clock |
355 | # 10 is the runtime save interval, for a monotonic clock |
|
|
356 | # 60 allows for the watchdog to kill the server. |
|
|
357 | |
355 | (aio_write $fh, 0, (length $value), $value, 0) <= 0 |
358 | (aio_write $fh, 0, (length $value), $value, 0) <= 0 |
356 | and return; |
359 | and return; |
357 | |
360 | |
358 | aio_fsync $fh |
361 | aio_fsync $fh |
359 | and return; |
362 | and return; |
… | |
… | |
2477 | |
2480 | |
2478 | $WRITE_RUNTIME_WATCHER = Event->timer ( |
2481 | $WRITE_RUNTIME_WATCHER = Event->timer ( |
2479 | data => WF_AUTOCANCEL, |
2482 | data => WF_AUTOCANCEL, |
2480 | after => 1, |
2483 | after => 1, |
2481 | interval => 10, |
2484 | interval => 10, |
|
|
2485 | prio => 6, # keep it lowest so it acts like a watchdog |
2482 | cb => Coro::unblock_sub { |
2486 | cb => Coro::unblock_sub { |
2483 | write_runtime |
2487 | write_runtime |
2484 | or warn "ERROR: unable to write runtime file: $!"; |
2488 | or warn "ERROR: unable to write runtime file: $!"; |
2485 | }, |
2489 | }, |
2486 | ); |
2490 | ); |