accepting SIGHUP. Reloads configuration and marks as point of interest
This commit is contained in:
parent
e7239091d7
commit
583d6d3147
2
build.sh
2
build.sh
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
RELEASE_VERSION="0.7.17"
|
RELEASE_VERSION="0.8.1"
|
||||||
|
|
||||||
buildpath=/tmp/gh-ost
|
buildpath=/tmp/gh-ost
|
||||||
target=gh-ost
|
target=gh-ost
|
||||||
|
@ -9,6 +9,8 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/github/gh-ost/go/base"
|
"github.com/github/gh-ost/go/base"
|
||||||
"github.com/github/gh-ost/go/logic"
|
"github.com/github/gh-ost/go/logic"
|
||||||
@ -17,6 +19,26 @@ import (
|
|||||||
|
|
||||||
var AppVersion string
|
var AppVersion string
|
||||||
|
|
||||||
|
// acceptSignals registers for OS signals
|
||||||
|
func acceptSignals(migrationContext *base.MigrationContext) {
|
||||||
|
c := make(chan os.Signal, 1)
|
||||||
|
|
||||||
|
signal.Notify(c, syscall.SIGHUP)
|
||||||
|
go func() {
|
||||||
|
for sig := range c {
|
||||||
|
switch sig {
|
||||||
|
case syscall.SIGHUP:
|
||||||
|
log.Infof("Received SIGHUP. Reloading configuration")
|
||||||
|
if err := migrationContext.ReadConfigFile(); err != nil {
|
||||||
|
log.Errore(err)
|
||||||
|
} else {
|
||||||
|
migrationContext.MarkPointOfInterest()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
// main is the application's entry point. It will either spawn a CLI or HTTP itnerfaces.
|
// main is the application's entry point. It will either spawn a CLI or HTTP itnerfaces.
|
||||||
func main() {
|
func main() {
|
||||||
migrationContext := base.GetMigrationContext()
|
migrationContext := base.GetMigrationContext()
|
||||||
@ -122,6 +144,7 @@ func main() {
|
|||||||
migrationContext.ApplyCredentials()
|
migrationContext.ApplyCredentials()
|
||||||
|
|
||||||
log.Infof("starting gh-ost %+v", AppVersion)
|
log.Infof("starting gh-ost %+v", AppVersion)
|
||||||
|
acceptSignals(migrationContext)
|
||||||
|
|
||||||
migrator := logic.NewMigrator()
|
migrator := logic.NewMigrator()
|
||||||
err := migrator.Migrate()
|
err := migrator.Migrate()
|
||||||
|
@ -606,7 +606,7 @@ func (this *Migrator) printStatus() {
|
|||||||
shouldPrintStatus = (elapsedSeconds%5 == 0)
|
shouldPrintStatus = (elapsedSeconds%5 == 0)
|
||||||
} else if elapsedSeconds <= 180 {
|
} else if elapsedSeconds <= 180 {
|
||||||
shouldPrintStatus = (elapsedSeconds%5 == 0)
|
shouldPrintStatus = (elapsedSeconds%5 == 0)
|
||||||
} else if this.migrationContext.TimeSincePointOfInterest() <= 60 {
|
} else if this.migrationContext.TimeSincePointOfInterest().Seconds() <= 60 {
|
||||||
shouldPrintStatus = (elapsedSeconds%5 == 0)
|
shouldPrintStatus = (elapsedSeconds%5 == 0)
|
||||||
} else {
|
} else {
|
||||||
shouldPrintStatus = (elapsedSeconds%30 == 0)
|
shouldPrintStatus = (elapsedSeconds%30 == 0)
|
||||||
|
@ -189,6 +189,7 @@ func (this *EventsStreamer) StreamEvents(canStopStreaming func() bool) error {
|
|||||||
for {
|
for {
|
||||||
if err := this.binlogReader.StreamEvents(canStopStreaming, this.eventsChannel); err != nil {
|
if err := this.binlogReader.StreamEvents(canStopStreaming, this.eventsChannel); err != nil {
|
||||||
log.Infof("StreamEvents encountered unexpected error: %+v", err)
|
log.Infof("StreamEvents encountered unexpected error: %+v", err)
|
||||||
|
this.migrationContext.MarkPointOfInterest()
|
||||||
time.Sleep(ReconnectStreamerSleepSeconds * time.Second)
|
time.Sleep(ReconnectStreamerSleepSeconds * time.Second)
|
||||||
|
|
||||||
// Reposition at same binlog file. Single attempt (TODO: make multiple attempts?)
|
// Reposition at same binlog file. Single attempt (TODO: make multiple attempts?)
|
||||||
|
Loading…
Reference in New Issue
Block a user