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

Adds support for starting dashboard server with service start #1472

Merged
merged 11 commits into from
Feb 21, 2022

Conversation

binaek
Copy link
Contributor

@binaek binaek commented Feb 18, 2022

steampipe service start

Adds a --dashboard flag to steampipe service start which starts the dashboard server with the steampipe service.

Also adds support for --dashboard-listen and --dashboard-port flags in the service start command (ignored if --dashboard is not used).

steampipe service start starts the service only.
steampipe service start --dashboard starts the service and the dashboard server

if steampipe service start --dashboard is given after a steampipe service start then only the dashboard server is started and postgres is left untouched

steampipe service stop

Stops both services if running - else stops only postgres and pluginmanager

--force force stops both (individually)

steampipe service restart

Restarts both (if running) else restarts only postgres

@binaek binaek added the enhancement New feature or request label Feb 18, 2022
@binaek binaek self-assigned this Feb 18, 2022
@binaek
Copy link
Contributor Author

binaek commented Feb 18, 2022

Outputs:

binaeksarkar@Binaeks-MacBook-Pro steampipe % steampipe service start --dashboard
Steampipe service is running:

Database:

  Host(s):            localhost, 127.0.0.1, 192.168.10.174
  Port:               9193
  Database:           steampipe
  User:               steampipe
  Password:           ****-****-****
  Connection string:  postgres://steampipe:****-****-****@localhost:9193/steampipe

Dashboard:

  Host(s):  localhost, 127.0.0.1, 192.168.10.174
  Port:     9194

Managing the Steampipe service:

  # Get status of the service
  steampipe service status
  
  # Restart the service
  steampipe service restart
  
  # Stop the service
  steampipe service stop

binaeksarkar@Binaeks-MacBook-Pro steampipe % steampipe service start         
Steampipe service is running:

Database:

  Host(s):            localhost, 127.0.0.1, 192.168.10.174
  Port:               9193
  Database:           steampipe
  User:               steampipe
  Password:           ****-****-****
  Connection string:  postgres://steampipe:****-****-****@localhost:9193/steampipe

Managing the Steampipe service:

  # Get status of the service
  steampipe service status
  
  # Restart the service
  steampipe service restart
  
  # Stop the service
  steampipe service stop

@binaek binaek linked an issue Feb 18, 2022 that may be closed by this pull request
if viper.GetBool(constants.ArgDashboardClient) {
err = dashboardserver.OpenBrowser(fmt.Sprintf("http://localhost:%d", serverPort))
if err != nil {
log.Println("[TRACE] dashboard server started but failed to start client", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a warning not trace? or should the status message indicate this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an inconvenience rather than an ERROR or WARNING. That's why I put it on TRACE.

We still get the port in the output.


var dashboardState *dashboardserver.DashboardServiceState
if viper.GetBool(constants.ArgDashboard) {
serverPort := dashboardserver.ListenPort(viper.GetInt(constants.ArgDashboardPort))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put into startDashBoardServer() function

@@ -279,6 +320,8 @@ func runServiceRestartCmd(cmd *cobra.Command, args []string) {
fmt.Println("Steampipe service is not running.")
return
}
currentDashboardState, err := dashboardserver.GetDashboardServiceState()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments describing our approach to restarting dashboard server

cmd/service.go Outdated
} else {
dbState, err = db_local.GetState()
if err != nil {
{ // Code fold
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this comment mean?

return nil
}

func setupDashboardServerlogSink() hclog.Logger {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

casing: setupDashboardServerLogSink

@kaidaguerre kaidaguerre merged commit 5fa2015 into main Feb 21, 2022
@kaidaguerre kaidaguerre deleted the service_report_1462 branch February 21, 2022 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optionally start report server with steampipe service
3 participants