Esempio n. 1
0
//RunContinuosly loads a local config file specified in cp,
//starts up and keeps running the broadcast,
//handling all the updates and scheduling.
func RunContinuosly(cp string) (err error) {
	for {
		var (
			c   *config.Config
			mgr *Manager
		)
		c, err = config.Get(cp)
		if err != nil {
			return
		}
		c.Notice("Reloading manager")
		mgr, err = New(c)
		if err != nil {
			return
		}

		mgr.Run()
	}
	return
}
Esempio n. 2
0
//DownloadBroadcast downloads a new broadcast from the server into a
//given directory, unzipping it, if it has .zip extension.
func DownloadBroadcast(c *config.Config, key, ft string, destDir string) (err error) {
	srcURL := fmt.Sprint(c.UpdateURL, "/presentation/", key, "/download?client=", c.Name)

	if ft != "zip" {
		err = downloadFile(srcURL, destDir+string(os.PathSeparator)+"broadcast."+ft)
		return
	}

	tempFileName := os.TempDir() + string(os.PathSeparator) + "unzip-" + strconv.Itoa(int(time.Now().Unix())) + ".zip"

	err = downloadFile(srcURL, tempFileName)
	if err != nil {
		return
	}

	err = unzip(destDir, tempFileName)

	err = os.Remove(tempFileName)
	if err != nil {
		c.Notice("Couldn't remove temporary file: %v", err)
	}

	return nil
}