示例#1
0
func upgrade() {
	UpgradeFileName := getUpgradeFileName()
	VersionFileName := getVersionFileName()
	UpgradeMarkerFileName := getUpgradeMarkerFileName()

	if setting.PathExists(UpgradeFileName) {
		if loadUpgradeFile(UpgradeFileName) {
			if !setting.PathExists(VersionFileName) {
				netCrunchSettings, err := readNetCrunchServerSettings()
				if err == nil {
					if updateNetCrunchDatasources(netCrunchSettings) &&
						writeVersionFile(VersionFileName) && removeFile(UpgradeFileName) {
						log.Info("NetCrunch: Upgrade")

						if setting.PathExists(UpgradeMarkerFileName) {
							SetInitializationSuccess()
							removeFile(UpgradeMarkerFileName)
						}
					} else {
						log.Info("NetCrunch: Upgrade error")
					}
				} else {
					log.Info("NetCrunch: Upgrade error")
				}
			}
		} else {
			log.Info("NetCrunch: Upgrade error")
		}
	}
}
示例#2
0
func Init() {
	StatusesFileName := getStatusesFileName()

	if setting.PathExists(StatusesFileName) {
		if !loadStatusesFile(StatusesFileName) {
			log.Info("NetCrunch: Failed to load statuses")
		}
	} else {
		DefaultStatusesFile := ini.Empty()
		DefaultStatusesFile.NewSection("Initialization")
		DefaultStatusesFile.Section("Initialization").NewKey("success", "false")
		if writeStatusesFile(StatusesFileName, DefaultStatusesFile) &&
			loadStatusesFile(StatusesFileName) {
			log.Info("NetCrunch: Statuses created")
		} else {
			log.Info("NetCrunch: Statuses creation error")
		}
	}

	upgrade()
}