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!") } }
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) }
func Install(template Template) { if template.Repository == "" { return } releasePath := download.DownloadLatestRelease(template.Repository) log.Debugf("Downloaded release path: %s", releasePath) sourcePath := filepath.Join(releasePath, template.SourcePath) copy(sourcePath, config.ResolvePath(template.DestinationPath)) insertAppKey(template) }
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) }
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!") } }