Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reloading is broken in v2.1 with rotate-logs: True #296

Open
ulidtko opened this issue Jul 24, 2024 · 8 comments
Open

Reloading is broken in v2.1 with rotate-logs: True #296

ulidtko opened this issue Jul 24, 2024 · 8 comments

Comments

@ulidtko
Copy link
Contributor

ulidtko commented Jul 24, 2024

As a sidetrack from #294, splitting off a separate issue.

Apparently since #274, app reloading is completely broken, unless rotate-logs has been set to false (i.e. stderr logging). The default for this option when absent in config, is True.

Steps to reproduce

  1. In the global keter config, set rotate-logs: True (or omit the option).
  2. Have any kind of webapp bundle running as incoming/app.keter.
  3. touch incoming/app.keter.

Expected result:

Reload of the app is performed, as if app.keter had changed to a new bundle version.

Actual result:

2024-07-24 19:05:06.41|Keter.AppManager:279|Info> Reloading Just App{appId=dummy} -> AIBundle "/opt/keter/incoming/dummy.keter" 1721847906
2024-07-24 19:05:06.41|Keter.AppManager:285|Error> Error occured when launching bundle "dummy": openFile: resource busy (file is locked)

This file is locked error comes from an attempt to open the (per-app) log-file for the second time for writing. When reloading, it is already open for writing once — by the previous RunningWebApp. Here:

keter/src/Keter/App.hs

Lines 240 to 243 in 6b7f1e4

case mappLogger of
Nothing -> withRunInIO $ \rio ->
bracketOnError (Log.createLoggerViaConfig ascKeterConfig (appLogName aid)) Log.loggerClose (rio . f var)
Just appLogger -> f var appLogger

(called from reload function in the same module)


Does not reproduce on keter 2.0.1 (with the legacy logger, obviously). cc @RiugaBachi @jappeace

I sincerely appreciate the refactoring effort, and the native support for logging to std streams 🚀
However this bug is a showstopper, we can't upgrade our infra to 2.1 due to this.

@jappeace
Copy link
Collaborator

we did fix some issue with regards to log rotation:
https://github.com/snoyberg/keter/blob/master/ChangeLog.md#215

@ulidtko
Copy link
Contributor Author

ulidtko commented Jul 25, 2024

@jappeace OK, great... but this is different issue.

@RiugaBachi
Copy link
Contributor

Thanks for finding this! I can take a deeper look at this over the weekend.

@m1-s
Copy link

m1-s commented Jan 28, 2025

I am hitting this as well after updating keter version. Any chance for a fix? Also it appears that by activating rotating logs, its not logging to systemd anymore. Before #274 it was possible to have logging to systemd as well as app specific logs on disk. It would be great to have this behavior restored.

@jappeace
Copy link
Collaborator

jappeace commented Jan 28, 2025

setting rotate-logs: False will use std err logging, which is captured by systemd (if you launch keter like that).

@m1-s
Copy link

m1-s commented Jan 28, 2025

Yes but then I am not getting app specific logs on disk anymore. I want both.

@jappeace
Copy link
Collaborator

that's a different issue 😅

@ulidtko
Copy link
Contributor Author

ulidtko commented Jan 30, 2025

Hi @m1-s, you can probably work out a concoction to get 2 log sinks like that. One arrangement that comes to mind, is keter rotate-logs: False → writes to systemd journald → configure journald with ForwardToSyslog=yes → add syslog.conf with config per your preference to write plaintext logs.

Or perhaps you can habituate to use journalctl directly, it's actually pretty usable IMHO. Has got many integrations with log depots, too... That's beside the point though.

What I wanted to say: you won't get both out of keter alone. If I remember the code correctly, it's an XOR: you either switch rotate-logs: True getting the traditional plaintext files (and, this issue with broken reload!) — or switch rotate-logs: False getting the stdout logging. Not both.

So that I don't come across as condescending: we, too, are stuck with the log/app-foo/current.log approach. Solidly entrenched. So much, that I dread the prospect of changing both the log format, and filepath structure, at once. Thence, our vendor-fork at Zoomin Software hasn't rebased to 2.1 still.

@jezen jezen mentioned this issue Feb 12, 2025
ktak-007 added a commit to ktak-007/keter that referenced this issue Feb 15, 2025
ktak-007 added a commit to ktak-007/keter that referenced this issue Feb 16, 2025
ktak-007 added a commit to ktak-007/keter that referenced this issue Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants