Skip to content

Commit

Permalink
fix maxmind finding
Browse files Browse the repository at this point in the history
Signed-off-by: Arnav Gupta <dev@championswimmer.in>
  • Loading branch information
championswimmer committed Aug 9, 2024
1 parent 7cf7e83 commit 9c04b53
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,6 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/championswimmer/duckdb-driver v0.2.1 h1:1wjIhRLE3NQjwMLntAPRXw5IdkxdMPkDxxr7i3vW4vE=
github.com/championswimmer/duckdb-driver v0.2.1/go.mod h1:zoGrzT9RpdOfCEOCDx4fZ1s87Rpx3D1QUIEzwxHWGLo=
github.com/championswimmer/duckdb-driver v0.2.2 h1:XG3La7Utu5ta25dK0XbKzKTTHcDI68QPmi+5rdeEox0=
github.com/championswimmer/duckdb-driver v0.2.2/go.mod h1:zoGrzT9RpdOfCEOCDx4fZ1s87Rpx3D1QUIEzwxHWGLo=
github.com/checkpoint-restore/go-criu/v4 v4.1.0/go.mod h1:xUQBLp4RLc5zJtWY++yjOoMoB5lihDt7fai+75m+rGw=
Expand Down
12 changes: 7 additions & 5 deletions onepixel.local.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ PORT=3000
ADMIN_USER_EMAIL=admin@onepixel.link

DB_LOGGING=error
DB_DIALECT=postgres
DATABASE_URL="host=127.0.0.1 user=postgres password=postgres dbname=onepixel port=5432 sslmode=disable TimeZone=UTC"
USE_FILE_DB=false
DB_DIALECT=sqlite
DATABASE_URL=app.db
# DATABASE_URL="host=127.0.0.1 user=postgres password=postgres dbname=onepixel port=5432 sslmode=disable TimeZone=UTC"
USE_FILE_DB=true

ADMIN_API_KEY="8DC4FCD4-DD71-4C18-B9C0-C38EF6790815"

JWT_SIGNING_KEY="ECkLlR74HWIZTG4GAFsmBFoqO7Nr30Bc"
JWT_DURATION_DAYS=90

EVENTDB_DIALECT=clickhouse
EVENTDB_URL="clickhouse://clickhouse:clickhouse@127.0.0.1:9000/onepixel?dial_timeout=10s&read_timeout=20s"
EVENTDB_DIALECT=duckdb
EVENTDB_URL=events.db
# EVENTDB_URL="clickhouse://clickhouse:clickhouse@127.0.0.1:9000/onepixel?dial_timeout=10s&read_timeout=20s"
8 changes: 4 additions & 4 deletions src/db/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,17 @@ func GetGeoIPDB() *geoip2.Reader {
// download file : https://git.io/GeoLite2-City.mmdb
createGeoIPDbOnce.Do(func() {
applogger.Warn("GeoIP: Initialising database")
fresh := utils.IsFileFresh(30, "/app/GeoLite2-City.mmdb")
fresh := utils.IsFileFresh(30, "./GeoLite2-City.mmdb")
if !fresh {
applogger.Error("GeoIP: GeoLite2-City.mmdb is not fresh; downloading again")
lo.Try(func() error {
return os.Remove("/app/GeoLite2-City.mmdb")
return os.Remove("./GeoLite2-City.mmdb")
})
lo.Must0(utils.DownloadFile("https://git.io/GeoLite2-City.mmdb", "/app/GeoLite2-City.mmdb"))
lo.Must0(utils.DownloadFile("https://git.io/GeoLite2-City.mmdb", "./GeoLite2-City.mmdb"))
applogger.Info("GeoIP: GeoLite2-City.mmdb downloaded")
}

reader = lo.Must(geoip2.Open("/app/GeoLite2-City.mmdb"))
reader = lo.Must(geoip2.Open("./GeoLite2-City.mmdb"))

})

Expand Down

0 comments on commit 9c04b53

Please sign in to comment.