Comments (5)
@JaniAnttonen I added close method for manually send the remaining log data after receiving signals.
Now you can call logger.close()
or logger.end()
to trigger LokiTransport's close method.
const gracefullyShutdown = () => {
Log.info(`SIGTERM / SIGINT signal received.`);
Log.info('Closing http server.');
server.close(() => {
Log.info('The final log.');
Log.close();
// wait for few secs to let transport send data to remote server
setTimeout(()=> {
process.exist(0);
}, 5000);
});
};
from winston-loki.
Thanks again for your contribution! I might've done a whoopsie (albeit not direct) with this. As of my latest knowledge, this library may now shut down gracefully, but only by itself. This means that it only waits for its own internal state (any unsent batches or unfinished requests) to finish. I don't have a fast answer for this but to make a patch to disable graceful shutdown with a configuration flag.
from winston-loki.
And you're right, there's a dependency that is used to handle the graceful shutdown. It's called async-exit-hook
from winston-loki.
Then again, it only does this:
exitHook(callback => {
this.sendBatchToLoki()
.then(() => callback())
.catch(() => callback())
})
That shouldn't trigger exit by itself on first glance, since the promised behavior is "Run some code when the process exits" but there's a part in async-exit-hook
that does something with process.exit
that might be the culprit:
function doExit() {
if (doExitDone) {
return;
}
doExitDone = true;
if (exit === true) {
// All handlers should be called even if the exit-hook handler was registered first
process.nextTick(process.exit.bind(null, code));
}
}
from winston-loki.
@JoHuang, I published a new version, 5.1.1
on npm that has a hotfix described here: https://github.com/JaniAnttonen/winston-loki/releases/tag/v5.1.1
from winston-loki.
Related Issues (20)
- Enable `replaceTimestamp` by default HOT 1
- Winston-loki not working with Grafana Cloud Loki HOT 3
- I cannot start project HOT 1
- use Symbol.for('level') when extracting label HOT 1
- useCustomFormat is broken
- Race condition in batching leading to lost logs HOT 1
- QUESTION: How many log levels are supported? HOT 2
- Feature Request: awaitable finishRequests method
- TypeError: winston_loki_1.default is not a constructor HOT 2
- Remote Loki HOT 1
- Possible to quit the batcher loop ASAP when closing? HOT 1
- [patch] A method to wait until all the logs are physically sent to winston HOT 3
- Docs: Add a section to explain how to make it work with nextjs and/or webpack HOT 5
- Snappy optionalDependency upgrade breaks build HOT 2
- CVE-2023-36665 protobufjs Dependency HOT 3
- Childlogger with additional labels
- NodeJS crash when batching is enabled
- Segmentation fault with swc & vitest in github action ubuntu-latest when using version 6.0.7
- Documentation improvement ideas
- logfmt syntax error with Grafana cloud
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from winston-loki.