-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* no need to pass env to sudo ; use pkexec when not launched by terminal * let desktop pattern define env vars to pass along * add --config and use it to point viper at correct file instead of setting home * allow only one menu process running * let menu listen for hup to accept new restart request * move pidpaths under menu/wait and make them consistent and only set once
- Loading branch information
Showing
11 changed files
with
358 additions
and
142 deletions.
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 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,46 @@ | ||
package cmd | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"syscall" | ||
|
||
"github.com/BitPonyLLC/huekeys/pkg/pidpath" | ||
|
||
"github.com/rs/zerolog/log" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
var restartCmd = &cobra.Command{ | ||
Use: "restart", | ||
Short: "Tells remote process to restart", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if !waitPidPath.IsRunning() { | ||
return errors.New("no remote process found") | ||
} | ||
|
||
if waitPidPath.IsOurs() { | ||
log.Info().Msg("received request to restart") | ||
cancelFunc() | ||
return nil | ||
} | ||
|
||
menuPidPath = pidpath.NewPidPath(viper.GetString("menu.pidpath"), 0666) | ||
if !menuPidPath.IsRunning() { | ||
return sendMsgViaIPC(cmd, "quit") | ||
} | ||
|
||
log.Info().Str("menu", menuPidPath.String()).Msg("sending restart signal to menu") | ||
err := syscall.Kill(menuPidPath.Getpid(), syscall.SIGHUP) | ||
if err != nil { | ||
return fmt.Errorf("unable to kill menu process: %w", err) | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(restartCmd) | ||
} |
Oops, something went wrong.