jpillora / overseer

Monitorable, gracefully restarting, self-upgrading binaries in Go (golang)
MIT License
2.33k stars 209 forks source link

Sanity Check Failed Echo Framework #64

Open putrafajarh opened 3 years ago

putrafajarh commented 3 years ago

im trying to integrate with Echo framework https://echo.labstack.com/

func main() {
    overseer.Run(overseer.Config{
        Program: server,
        Address: viper.GetString("server.address"),
        Fetcher: &fetcher.File{
            Path: "/home/putrafajarh/code/heimdall/heimdall",
        },
        Debug: true,
    })
}

func server(state overseer.State) {
    dbHost := viper.GetString(`database.host`)
    dbPort := viper.GetString(`database.port`)
    dbUser := viper.GetString(`database.user`)
    dbPass := viper.GetString(`database.pass`)
    dbName := viper.GetString(`database.name`)
    connection := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s", dbUser, dbPass, dbHost, dbPort, dbName)
    val := url.Values{}
    val.Add("parseTime", "1")
    val.Add("loc", "Asia/Jakarta")
    dsn := fmt.Sprintf("%s?%s", connection, val.Encode())
    dbConn, err := sql.Open(`mysql`, dsn)

    if err != nil {
        log.Fatal(err)
    }
    err = dbConn.Ping()
    if err != nil {
        log.Fatal(err)
    }

    defer func() {
        err := dbConn.Close()
        if err != nil {
            log.Fatal(err)
        }
    }()

    e := echo.New()
    e.Listener = state.Listener
    middL := _articleHttpDeliveryMiddleware.InitMiddleware()
    e.Use(middL.CORS)
    authorRepo := _authorRepo.NewMysqlAuthorRepository(dbConn)
    ar := _articleRepo.NewMysqlArticleRepository(dbConn)

    timeoutContext := time.Duration(viper.GetInt("context.timeout")) * time.Second
    au := _articleUcase.NewArticleUsecase(ar, authorRepo, timeoutContext)
    _articleHttpDelivery.NewArticleHandler(e, au)

    // s := &http.Server{
    //  Addr: viper.GetString("server.address"),
    // }

    fmt.Printf("app#%s (%s) listening...\n", VersionID, state.ID)
    log.Fatal(e.Start(viper.GetString("server.address")))
    fmt.Printf("app#%s (%s) exiting...\n", VersionID, state.ID)
}

i got this log, and code changes doesnt work when i try to hit using postman

2020/12/11 07:32:32 [overseer master] proxy signal (urgent I/O condition)
2020/12/11 07:32:33 [overseer master] streaming update...
2020/12/11 07:32:33 [overseer master] proxy signal (urgent I/O condition)
2020/12/11 07:32:33 [overseer master] proxy signal (urgent I/O condition)
2020/12/11 07:32:33 [overseer master] proxy signal (urgent I/O condition)
2020/12/11 07:32:33 [overseer master] sanity check failed
2020/12/11 07:32:33 [overseer master] checking for updates...
2020/12/11 07:32:34 [overseer master] no updates
nfoerster commented 3 years ago

I had the same issue but I solved it after debugging the token in and token out. The problem is, that the current code just expects from the new binary that the returned token is the only thing returned by the program. My program unfortunately used a deprecated function, which will be returned by go by default.

I edited the warning "sanity check failed" for the input and output token. As you can see the input token is bb49a04d65de655a, however, the output of the program is the warning + the correct token.

You can use my forked repo to test the token output:

go get github.com/nfoerster/overseer@a9d662d

2021/02/08 14:44:28 [overseer master] sanity check failed bb49a04d65de655a WARNING: Package "github.com/golang/protobuf/protoc-gen-go/generator" is deprecated.
        A future release of golang/protobuf will delete this package,
        which has long been excluded from the compatibility promise.

bb49a04d65de655a

After removing the warning, the program continues updating.

I think two points have to be fixed here:

yangyuan6 commented 3 years ago

See pull-request https://github.com/jpillora/overseer/pull/72

shuiYe-704265085 commented 1 year ago

I also encountered the same problem. Due to a relatively short time frame, I had to find another way to find a library that was relatively easy to use and just met my non pending process update needs. Please refer to:"https://www.mianshigee.com/project/inconshreveable-go-update/"