-
Notifications
You must be signed in to change notification settings - Fork 1
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
Remove section for executing resetDell
periodically
#101
Conversation
|
||
env.Stop() | ||
return env.Wait() | ||
return resetDell(ctx) |
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.
Please refactor the caller of this facntion.
There is no longer a need to run this function as a goroutine.
https://github.com/cybozu-go/setup-hw/blob/v1.15.1/pkg/monitor-hw/cmd/root.go#L107-L109
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.
I refactored it by deleting monitor functions. Also, I changed startExporter()
to keep running without well.Wait()
.
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.
Please check whether monitor-hw exits normally.
As far as I have confirmed, the following test programs did not terminate when receiving signals.
I think monitor-hw will be the same.
package main
import (
"context"
"io"
"net/http"
"time"
"github.com/cybozu-go/log"
"github.com/cybozu-go/well"
"github.com/spf13/cobra"
)
func startExporter() error {
well.Go(func(ctx context.Context) error {
for {
log.Info("Do collector.Update(ctx)", nil)
select {
case <-time.After(time.Second):
case <-ctx.Done():
return nil
}
}
})
mux := http.NewServeMux()
mux.HandleFunc("/metrics", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Hello")
})
return http.ListenAndServe(":9105", mux)
}
var rootCmd = &cobra.Command{
PersistentPreRun: func(cmd *cobra.Command, args []string) {
cmd.SilenceUsage = true
err := well.LogConfig{}.Apply()
if err != nil {
log.ErrorExit(err)
}
},
RunE: func(cmd *cobra.Command, args []string) error {
return startExporter()
},
}
func main() {
err := rootCmd.Execute()
if err != nil {
log.ErrorExit(err)
}
}
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.
Thank you.
I rollbacked to use well.HTTPServer.ListenAndServe()
and call well.Stop()
and well.Wait
at the parent function.
Signed-off-by: Tomoki Sugiura <tomoki-sugiura@cybozu.co.jp>
0a2ee8c
to
9ed1651
Compare
Signed-off-by: Tomoki Sugiura <tomoki-sugiura@cybozu.co.jp>
9ed1651
to
4422922
Compare
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.
LGTM
No description provided.