-
Notifications
You must be signed in to change notification settings - Fork 31
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
Feat: multi entry #223
Merged
Merged
Feat: multi entry #223
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
53be2b5
feat: split http and wails into two entrypoints
rolznz 8c46ba1
fix: remove duplicate backend launch code
rolznz c1687ba
chore: rename new service function
rolznz c958084
fix: graceful shutdown in http and wails modes
rolznz e15b746
Merge branch 'feat/wails-v2' into feat/multi-entry
rolznz 73c4b75
chore: remove unused code
rolznz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//go:build !wails || http | ||
// +build !wails http | ||
|
||
// (http tag above is simply to fix go language server issue and is not needed to build the app) | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
"sync" | ||
"time" | ||
|
||
echologrus "github.com/davrux/echo-logrus/v4" | ||
"github.com/labstack/echo/v4" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
// ignore this warning: we use build tags | ||
// this function will only be executed if no wails tag is set | ||
func main() { | ||
log.Info("NWC Starting in HTTP mode") | ||
var wg sync.WaitGroup | ||
wg.Add(1) | ||
|
||
svc := NewService(&wg) | ||
|
||
if svc.cfg.CookieSecret == "" { | ||
svc.Logger.Fatalf("required key COOKIE_SECRET missing value") | ||
} | ||
|
||
echologrus.Logger = svc.Logger | ||
e := echo.New() | ||
|
||
//register shared routes | ||
svc.RegisterSharedRoutes(e) | ||
//start Echo server | ||
go func() { | ||
if err := e.Start(fmt.Sprintf(":%v", svc.cfg.Port)); err != nil && err != http.ErrServerClosed { | ||
e.Logger.Fatal("shutting down the server") | ||
} | ||
//handle graceful shutdown | ||
<-svc.ctx.Done() | ||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | ||
defer cancel() | ||
e.Shutdown(ctx) | ||
svc.Logger.Info("Echo server exited") | ||
wg.Done() | ||
}() | ||
|
||
wg.Wait() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//go:build wails | ||
// +build wails | ||
|
||
package main | ||
|
||
import ( | ||
"sync" | ||
|
||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
// ignore this warning: we use build tags | ||
// this function will only be executed if the wails tag is set | ||
func main() { | ||
log.Info("NWC Starting in WAILS mode") | ||
var wg sync.WaitGroup | ||
wg.Add(1) | ||
|
||
svc := NewService(&wg) | ||
|
||
go func() { | ||
app := NewApp(svc) | ||
LaunchWailsApp(app) | ||
wg.Done() | ||
svc.Logger.Info("Wails app exited") | ||
}() | ||
|
||
wg.Wait() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the service is run on a separate process. The go process exits before that process is gracefully shut down (e.g. disconnect from the relay). The app wasn't actually exiting gracefully though. I have fixed these now, maybe we can review it together?