forked from Silverfish/proton-bridge
GODT-2039: bridge monitors bridge-gui via its PID (port from v2.4)
This commit is contained in:
@ -69,15 +69,16 @@ const (
|
||||
|
||||
// Hidden flags.
|
||||
const (
|
||||
flagLauncher = "launcher"
|
||||
flagNoWindow = "no-window"
|
||||
flagLauncher = "launcher"
|
||||
flagNoWindow = "no-window"
|
||||
flagParentPID = "parent-pid"
|
||||
)
|
||||
|
||||
const (
|
||||
appUsage = "Proton Mail IMAP and SMTP Bridge"
|
||||
)
|
||||
|
||||
func New() *cli.App {
|
||||
func New() *cli.App { //nolint:funlen
|
||||
app := cli.NewApp()
|
||||
|
||||
app.Name = constants.FullAppName
|
||||
@ -133,6 +134,11 @@ func New() *cli.App {
|
||||
Usage: "The launcher used to start the app",
|
||||
Hidden: true,
|
||||
},
|
||||
&cli.IntFlag{
|
||||
Name: flagParentPID,
|
||||
Usage: "Process ID of the parent",
|
||||
Hidden: true,
|
||||
},
|
||||
}
|
||||
|
||||
app.Action = run
|
||||
@ -203,9 +209,14 @@ func run(c *cli.Context) error { //nolint:funlen
|
||||
b.PushError(bridge.ErrVaultCorrupt)
|
||||
}
|
||||
|
||||
parentPID := -1
|
||||
if pid := c.Int(flagParentPID); pid != 0 {
|
||||
parentPID = pid
|
||||
}
|
||||
|
||||
// Run the frontend.
|
||||
return runFrontend(c, crashHandler, restarter,
|
||||
locations, b, eventCh,
|
||||
locations, b, eventCh, parentPID,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
@ -38,6 +38,7 @@ func runFrontend(
|
||||
locations *locations.Locations,
|
||||
bridge *bridge.Bridge,
|
||||
eventCh <-chan events.Event,
|
||||
parentPID int,
|
||||
) error {
|
||||
switch {
|
||||
case c.Bool(flagCLI):
|
||||
@ -47,7 +48,7 @@ func runFrontend(
|
||||
select {}
|
||||
|
||||
case c.Bool(flagGRPC):
|
||||
service, err := grpc.NewService(crashHandler, restarter, locations, bridge, eventCh, !c.Bool(flagNoWindow))
|
||||
service, err := grpc.NewService(crashHandler, restarter, locations, bridge, eventCh, !c.Bool(flagNoWindow), parentPID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create service: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user