mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 07:33:12 +09:00
Add autosave tracking and statistics
Detect when autosaves are made and track the size in a Prometheus gague.
This commit is contained in:
1 parent
139585f8c6
commit
e908c5069b
4 files changed
+69
No files matched your search
@@ -349,6 +349,18 @@ const outputHeuristics = [
|
||||
}
|
||||
},
|
||||
|
||||
// Message indicating the server has started an autosave
|
||||
{
|
||||
filter: {
|
||||
type: 'log',
|
||||
message: /^Saving to _autosave\d+ \((non-)?blocking\)\.$/,
|
||||
},
|
||||
action: function(output) {
|
||||
let name = /^Saving to (_autosave\d+) /.exec(output.message)[1];
|
||||
this.emit('_autosave', name);
|
||||
},
|
||||
},
|
||||
|
||||
// Message indicating the server has finished saving
|
||||
{
|
||||
filter: {
|
||||
@@ -419,6 +431,8 @@ const outputHeuristics = [
|
||||
* output - invoked with parsed output from Factorio
|
||||
* rcon-ready - invoked when the RCON client has connected
|
||||
* game-ready - invoked when the server is finished starting up
|
||||
* autosave-start - invoked when the server starts an autosave
|
||||
* autosave-fnished - invoked when the autosave finished
|
||||
* exit - invoked when the sterver has exited
|
||||
*/
|
||||
class FactorioServer extends events.EventEmitter {
|
||||
@@ -454,6 +468,20 @@ class FactorioServer extends events.EventEmitter {
|
||||
|
||||
this._stdout = new LineSplitter((line) => { this._handleOutput(line, 'stdout'); });
|
||||
this._stderr = new LineSplitter((line) => { this._handleOutput(line, 'stderr'); });
|
||||
|
||||
// Track autosaving
|
||||
this._runningAutosave = null;
|
||||
this.on("_autosave", function(name) {
|
||||
this.emit("autosave-start", name);
|
||||
this._runningAutosave = name;
|
||||
})
|
||||
|
||||
this.on("_saved", function() {
|
||||
if (this._runningAutosave) {
|
||||
this.emit("autosave-finished", this._runningAutosave);
|
||||
this._runningAutosave = null;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
_check(expectedStates) {
|
||||
@@ -645,6 +673,7 @@ class FactorioServer extends events.EventEmitter {
|
||||
this._rconReady = false;
|
||||
this._gameReady = false;
|
||||
this._unexpected = [];
|
||||
this._runningAutosave = null;
|
||||
|
||||
this.emit("exit");
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user