Skip to content

Commit

Permalink
Refactor self update check, once more
Browse files Browse the repository at this point in the history
  • Loading branch information
rabilrbl committed Jan 26, 2024
1 parent a4082bc commit 9c133a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/background.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func RunInBackground(args string) error {
}

cmdArgs := strings.Fields(args)
cmdArgs = append(cmdArgs, "--skip-update-check")
// Run JioTVServer function as a separate process
cmd := exec.Command(binaryExecutablePath, append([]string{"serve"}, cmdArgs...)...)
err = cmd.Start()
Expand Down
12 changes: 10 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ func main() {
Usage: "Start JioTV Go server",
Description: "The serve command starts JioTV Go server, and listens on the host and port. The default host is localhost and port is 5001.",
Action: func(c *cli.Context) error {
cmd.PrintIfUpdateAvailable(c)
if c.Bool("skip-update-check") {
fmt.Println("INFO: Skipping update check")
} else {
cmd.PrintIfUpdateAvailable(c)
}
host := c.String("host")
// overwrite host if --public flag is passed
if c.Bool("public") {
Expand Down Expand Up @@ -70,6 +74,10 @@ func main() {
Name: "prefork",
Usage: "Enable prefork. This will enable preforking the server to multiple processes. This is useful for production deployment.",
},
&cli.BoolFlag{
Name: "skip-update-check",
Usage: "Skip checking for update on startup",
},
},
},
{
Expand Down Expand Up @@ -177,6 +185,7 @@ func main() {
Usage: "Run JioTV Go server in the background",
Description: "The run command starts JioTV Go server in the background. It runs the JioTVServer function in a separate goroutine.",
Action: func(c *cli.Context) error {
cmd.PrintIfUpdateAvailable(c)
args := c.String("args")
return cmd.RunInBackground(args)
},
Expand All @@ -195,7 +204,6 @@ func main() {
Usage: "Stop JioTV Go server running in the background",
Description: "The stop command stops the JioTV Go server running in the background.",
Action: func(c *cli.Context) error {
cmd.PrintIfUpdateAvailable(c)
return cmd.StopBackground()
},
},
Expand Down

0 comments on commit 9c133a9

Please sign in to comment.