Exemple #1
0
func deployServer() {
	dir := config.ResolvePath(config.Read().ServerDir)
	term.Section()
	if !directoryExists(dir) {
		term.Println("Directory does not exist: " + dir)
		term.Println("Skipping server deploy")
		return
	}
	term.Println("Packaging server files for upload...")
	archive, bytes, err := hosting.PrepareArchive(dir)
	if err != nil {
		term.Section()
		term.Println(err.Error())
		return
	}
	term.Printf("Uploading %.2f MB...\n", float64(bytes)/(1024.0*1024.0))
	progress := term.ShowProgressBar(bytes)

	err = hosting.UploadServer(archive, progress)
	if err != nil {
		progress.Finish()
		term.Section()
		term.Println("Error deploying server: " + err.Error())
	} else {
		progress.Finish()
		term.Section()
		term.Println("Server deploy completed!")
	}
}
Exemple #2
0
func createServerDir() {
	dir := config.Read().ServerDir
	if _, err := os.Stat(dir); os.IsNotExist(err) {
		err = os.MkdirAll(dir, 0700)
		fail.Handle(err)
		log.Debugf("Created server directory '%s'", dir)
	} else {
		log.Debugf("Not creating server directory. '%s' already exists.", dir)
	}
}
Exemple #3
0
func DoServe(c *cli.Context) {
	useOptions(c)
	publicDir := config.ResolvePath(config.Read().PublicDir)
	term.Println("Serving your public directory at http://localhost:9000/")
	term.Println("Press Ctrl-C to stop.")
	term.Section()

	http.Handle("/", http.FileServer(http.Dir(publicDir)))
	http.ListenAndServe(":9000", nil)
}
Exemple #4
0
func addHeaders(req *http.Request) {
	sessionID := session.ReadSessionID()
	appKey := config.Read().AppKey

	if sessionID != "" {
		req.Header.Add("x-appstax-sessionid", sessionID)
	}
	if appKey != "" {
		req.Header.Add("x-appstax-appkey", appKey)
	}
}
Exemple #5
0
func selectBaseUrl() string {
	url := defaultBaseUrl
	configBaseUrl = config.Read().ApiBaseUrl
	if configBaseUrl != "" {
		url = configBaseUrl
	}
	if optionBaseUrl != "" {
		url = optionBaseUrl
	}
	log.Infof("Using base url: %s", url)
	return url
}
Exemple #6
0
func insertAppKey(template Template) {
	if template.AppKeyInFile == "" {
		return
	}
	path := config.ResolvePath(template.AppKeyInFile)
	bytes, err := ioutil.ReadFile(path)
	fail.Handle(err)
	text := string(bytes)

	text = strings.Replace(text, "<<appstax-app-key>>", config.Read().AppKey, -1)
	err = ioutil.WriteFile(path, []byte(text), 0644)
	fail.Handle(err)
}
Exemple #7
0
func deployPublic() {
	selectSubdomainIfNeeded()
	dir := config.ResolvePath(config.Read().PublicDir)
	term.Section()
	if !directoryExists(dir) {
		term.Println("Directory does not exist: " + dir)
		term.Println("Skipping public deploy")
		return
	}
	term.Println("Packaging public files for upload...")
	archive, bytes, _ := hosting.PrepareArchive(dir)
	term.Printf("Uploading %.2f MB...\n", float64(bytes)/(1024.0*1024.0))
	progress := term.ShowProgressBar(bytes)
	err := hosting.UploadStatic(archive, progress)
	if err != nil {
		progress.Finish()
		term.Section()
		term.Println("Error deploying public files: " + err.Error())
	} else {
		progress.Finish()
		term.Section()
		term.Println("Public deploy completed!")
	}
}