move metno initialization earlier so less work is done if the environment variable is not set
This commit is contained in:
parent
b2cb5d537f
commit
87ffe7d598
1 changed files with 8 additions and 7 deletions
15
src/main.zig
15
src/main.zig
|
|
@ -9,6 +9,7 @@ const GeoCache = @import("location/GeoCache.zig");
|
|||
const Airports = @import("location/Airports.zig");
|
||||
const Resolver = @import("location/resolver.zig").Resolver;
|
||||
const GeoLite2 = @import("location/GeoLite2.zig");
|
||||
const version = @import("build_options").version;
|
||||
|
||||
pub fn main() !u8 {
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
|
|
@ -18,7 +19,7 @@ pub fn main() !u8 {
|
|||
const cfg = try Config.load(allocator);
|
||||
defer cfg.deinit(allocator);
|
||||
|
||||
std.log.info("wttr starting on {s}:{d}", .{ cfg.listen_host, cfg.listen_port });
|
||||
std.log.info("wttr version {s} starting on {s}:{d}", .{ version, cfg.listen_host, cfg.listen_port });
|
||||
std.log.info("Cache size: {d}", .{cfg.cache_size});
|
||||
std.log.info("Cache dir: {s}", .{cfg.cache_dir});
|
||||
std.log.info("GeoLite2 path: {s}", .{cfg.geolite_path});
|
||||
|
|
@ -28,6 +29,12 @@ pub fn main() !u8 {
|
|||
std.log.info("Geocache: in-memory only", .{});
|
||||
}
|
||||
|
||||
var metno = MetNo.init(allocator, null) catch |err| {
|
||||
if (err == MetNo.MissingIdentificationError) return 1;
|
||||
return err;
|
||||
};
|
||||
defer metno.deinit();
|
||||
|
||||
// Ensure GeoLite2 database exists
|
||||
try GeoLite2.ensureDatabase(allocator, cfg.geolite_path);
|
||||
|
||||
|
|
@ -67,12 +74,6 @@ pub fn main() !u8 {
|
|||
});
|
||||
defer rate_limiter.deinit();
|
||||
|
||||
var metno = MetNo.init(allocator, null) catch |err| {
|
||||
if (err == MetNo.MissingIdentificationError) return 1;
|
||||
return err;
|
||||
};
|
||||
defer metno.deinit();
|
||||
|
||||
var server = try Server.init(allocator, cfg.listen_host, cfg.listen_port, .{
|
||||
.provider = metno.provider(cache),
|
||||
.resolver = &resolver,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue