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

[Installer] Installer fixes #181

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [4.5.1] 6/5/2024

**Installer** Fix issue where slow machines would not source database files fast enough leading to a 5-minute execution timeout and a half-sourced database.

## [4.5.0] 6/1/2024

**Spire Auto Updates** Add ability to disable auto updates on bootup via **eqemu_config.json** option **spire.disable_auto_updates** if set.
Expand Down
2 changes: 2 additions & 0 deletions boot/inject_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/Akkadius/spire/internal/questapi"
"github.com/Akkadius/spire/internal/spire"
"github.com/Akkadius/spire/internal/telnet"
"github.com/Akkadius/spire/internal/unzip"
"github.com/Akkadius/spire/internal/user"
"github.com/Akkadius/spire/internal/websocket"
pluralize "github.com/gertd/go-pluralize"
Expand Down Expand Up @@ -54,4 +55,5 @@ var serviceSet = wire.NewSet(
eqemuserver.NewUpdater,
eqemuserver.NewLauncher,
eqemuserver.NewQuestHotReloadWatcher,
unzip.NewUnzipper,
)
4 changes: 3 additions & 1 deletion boot/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 16 additions & 9 deletions internal/assets/spire_assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/Akkadius/spire/internal/download"
"github.com/Akkadius/spire/internal/env"
appmiddleware "github.com/Akkadius/spire/internal/http/middleware"
"github.com/Akkadius/spire/internal/logger"
"github.com/Akkadius/spire/internal/pathmgmt"
"github.com/Akkadius/spire/internal/unzip"
"github.com/labstack/echo/v4"
Expand All @@ -20,13 +21,19 @@ import (

type SpireAssets struct {
pathmanager *pathmgmt.PathManagement
logger *logger.AppLogger
unzipper *unzip.Unzipper
}

func NewSpireAssets(
pathmanager *pathmgmt.PathManagement,
logger *logger.AppLogger,
unzipper *unzip.Unzipper,
) *SpireAssets {
return &SpireAssets{
pathmanager: pathmanager,
logger: logger,
unzipper: unzipper,
}
}

Expand Down Expand Up @@ -72,7 +79,7 @@ func (a SpireAssets) ServeStatic() echo.MiddlewareFunc {
}

func (a SpireAssets) downloadAssets(cachedir string) {
fmt.Printf("Downloading [eq-asset-preview] latest release\n")
a.logger.Info().Any("repo", assetRepo).Msg("Downloading latest release")

// zip file path
dumpZip := filepath.Join(os.TempDir(), "/build.zip")
Expand All @@ -86,8 +93,7 @@ func (a SpireAssets) downloadAssets(cachedir string) {
log.Fatal(err)
}

// unzip the file
err = unzip.New(dumpZip, cachedir).Extract()
err = a.unzipper.Extract(dumpZip, cachedir)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -154,11 +160,11 @@ func (a SpireAssets) CheckForAssets() {
// get latest release version
resp, err := http.Get(fmt.Sprintf("https://api.github.com/repos/%v/releases/latest", assetRepo))
if err != nil {
fmt.Printf("could not get latest release version for [%v] %v", assetRepo, err)
a.logger.Info().Err(err).Any("repo", assetRepo).Msg("Could not get latest release version")
}

if resp == nil {
fmt.Printf("could not get latest release version for [%v] nil response", assetRepo)
a.logger.Info().Any("repo", assetRepo).Msg("Could not get latest release version")
return
}

Expand Down Expand Up @@ -202,10 +208,11 @@ func (a SpireAssets) CheckForAssets() {
// check if current version is the same as the latest release version
remoteRelease := strings.ReplaceAll(release.TagName, "v", "")
if len(remoteRelease) > 0 && packageJsonStruct.Version != remoteRelease {
fmt.Printf(
"New version available, downloading [eq-asset-preview] release [%v]\n",
release.TagName,
)
a.logger.Info().
Any("repo", assetRepo).
Any("version", release.TagName).
Msg("New version available, downloading")

a.downloadAssets(cachedir)
}

Expand Down
4 changes: 2 additions & 2 deletions internal/database/connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ func (c *Connections) SpireMigrate(drop bool) error {

// only emit creation message when the table doesn't actually exist
if !migrator.HasTable(table) {
c.logger.Info().Msgf("[Database] Creating table [%v]", table.TableName())
c.logger.Info().Any("table", table.TableName()).Msg("Creating table")
} else {
c.logger.DebugVvv().Msgf("[Database] Already has table [%v]", table.TableName())
c.logger.DebugVvv().Any("table", table.TableName()).Msg("Already has table")
}

// always run migration incase there are schema changes
Expand Down
Loading