Пример #1
0
func main() {
	if status := Init(); status != 0 {
		return
	}
	defer database.Close()
	for table := 1; table <= 8; table++ {
		rows, err := database.GetStoragePathRows(table)
		if err != nil {
			fmt.Printf("%s\n", err)
			continue
		}
		for {
			if path, err := rows.ScanNext(); err != nil {
				if err != io.EOF {
					fmt.Printf("%s\n", err)
				}
				break
			} else {
				fmt.Printf("%s\n", path)
				if err := storage.FdfsDelete(path); err != nil {
					fmt.Printf("%s\n", err)
				}
			}
		}
		rows.Close()
	}

}
Пример #2
0
func Main() int {
	if status := Init(); status != 0 {
		return status
	}
	defer func() {
		progressLog.Close()
		errLog.Close()
		database.Close()
	}()

	cycleExit := make(chan int, 1)
	termNotify := make(chan int, 1)

	go cycle(cycleExit, termNotify)

	term := make(chan os.Signal, 1)
	signal.Notify(term, os.Interrupt, syscall.SIGTERM)
	select {
	case <-term:
		termNotify <- 1
		<-cycleExit
		exitLog.Println("Received SIGTERM, exiting gracefully...")
	case <-cycleExit:
		exitLog.Println("Migration stop, end of phase 1 or encountering error...")
	}

	return 0
}