Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature/eager init #74

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

Closed
fulleni wants to merge 16 commits into main from feature/eager-init
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
5fca19c
feat(server): implement eager-loading entrypoint
fulleni Oct 19, 2025
b45e889
refactor(server): simplify AppDependencies for eager loading
fulleni Oct 19, 2025
f5b81e3
refactor(server): remove lazy init from root middleware
fulleni Oct 19, 2025
895be8a
refactor(server): configure custom executable entrypoint
fulleni Oct 19, 2025
048eaa3
docs(readme): add eager loading architecture highlight
fulleni Oct 19, 2025
fb0795c
docs(changelog): document eager loading refactor
fulleni Oct 19, 2025
22d92ea
refactor(server): move logger setup to eager entrypoint
fulleni Oct 19, 2025
7765ee0
fix(server): correct entrypoint logic and linter warnings
fulleni Oct 19, 2025
0864728
feat(bin): implement hot reload for Dart Frog server
fulleni Oct 19, 2025
7014237
refactor(loading): update eager loading description for Dart Frog com...
fulleni Oct 19, 2025
056fde1
refactor(server): remove unused reset logic from AppDependencies
fulleni Oct 19, 2025
758765d
style: format
fulleni Oct 19, 2025
a46581e
feat(server): implement graceful shutdown and atomic logging
fulleni Oct 19, 2025
38a3a5d
fix(bin): handle SIGTERM signal support on non-Windows platforms
fulleni Oct 19, 2025
a588d98
fix(server): resolve handler type ambiguity in entrypoint
fulleni Oct 19, 2025
301c0e4
fix(server): ensure fatal startup logs are captured before exit
fulleni Oct 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(server): move logger setup to eager entrypoint
Relocates the global logger configuration from the root middleware (`routes/_middleware.dart`) to the new eager-loading entrypoint (`bin/main.dart`).
This is an architectural improvement that ensures the logger is configured exactly once when the application process starts, rather than within a middleware that could be re-instantiated. It makes the startup sequence more robust and simplifies the root middleware's responsibilities.
  • Loading branch information
fulleni committed Oct 19, 2025
commit 22d92ea712329d9b37bf08af4a68878c3fd0a02a

Some comments aren't visible on the classic Files Changed page.

20 changes: 20 additions & 0 deletions bin/main.dart
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ import '../.dart_frog/server.dart' as server;
/// "fail-fast" approach suitable for production environments.
Future<void> main(List<String> args) async {
// Use a local logger for startup-specific messages.
// This is also the ideal place to configure the root logger for the entire
// application, as it's guaranteed to run only once at startup.
Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((record) {
// A more detailed logger that includes the error and stack trace.
// ignore: avoid_print
print(
'${record.level.name}: ${record.time}: ${record.loggerName}: '
'${record.message}',
);
if (record.error != null) {
// ignore: avoid_print
print(' ERROR: ${record.error}');
}
if (record.stackTrace != null) {
// ignore: avoid_print
print(' STACK TRACE: ${record.stackTrace}');
}
});

final log = Logger('EagerEntrypoint');

try {
Expand Down
26 changes: 0 additions & 26 deletions routes/_middleware.dart
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,12 @@ import 'package:mongo_dart/mongo_dart.dart';
// --- Middleware Definition ---
final _log = Logger('RootMiddleware');

// A flag to ensure the logger is only configured once for the application's
// entire lifecycle.
bool _loggerConfigured = false;

Handler middleware(Handler handler) {
// This is the root middleware for the entire API. It's responsible for
// providing all shared dependencies to the request context.
// The order of `.use()` calls is important: the last one in the chain
// runs first.

// This check ensures that the logger is configured only once.
if (!_loggerConfigured) {
Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((record) {
// A more detailed logger that includes the error and stack trace.
// ignore: avoid_print
print(
'${record.level.name}: ${record.time}: ${record.loggerName}: '
'${record.message}',
);
if (record.error != null) {
// ignore: avoid_print
print(' ERROR: ${record.error}');
}
if (record.stackTrace != null) {
// ignore: avoid_print
print(' STACK TRACE: ${record.stackTrace}');
}
});
_loggerConfigured = true;
}

return handler
// --- Core Middleware ---
// These run after all dependencies have been provided.
Expand Down

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /