Beispiel #1
0
func main() {
	conf := config.NewConfig(os.Getenv("PWD") + "/config.json")
	defer func() {
		conf.Save()
	}()

	n := len(conf.Users())
	complete_chan := make(chan string, n)
	for name, user := range conf.Users() {
		go func(n string, u *config.User) {
			sync(n, u)
			complete_chan <- n + " is done"
		}(name, user)
	}
	log.Println("wait for complete")
	for i := 0; i < n; i++ {
		log.Print(<-complete_chan)
	}
	log.Println("done")
}
Beispiel #2
0
func main() {
	var configFile string
	configFiles := []string{"/etc/supervisorg/supervisor.conf", "supervisor.conf"}

	flag.StringVar(&configFile, "configuration", "", "Default: "+strings.Join(configFiles, ", "))
	flag.StringVar(&configFile, "c", "", "Default: "+strings.Join(configFiles, ", "))
	flag.Parse()

	if configFile != "" {
		configFiles = []string{configFile}
	}

	f, err := chooseConfiFile(configFiles)
	if err != nil {
		log.Println(err.Error())
		os.Exit(1)
	}
	stopChan := make(chan struct{})
	conf, err := config.NewConfig(f)
	for _, program := range conf.Programs {
		go runProgram(program, stopChan)
	}
}
Beispiel #3
0
 * To change this template use File | Settings | File Templates.
 */
package main

import (
	"config"
	"controllers"
	"fmt"
	"io/ioutil"
	"net/http"
	"strings"
	"syscall"
	"time"
)

var Config = config.NewConfig("config/app.json")

type MaxAgeResponseWriter struct {
	http.ResponseWriter
	maxAge time.Duration // seconds
}

func (w MaxAgeResponseWriter) WriteHeader(code int) {
	if code == 200 { //only cache the response if it's successful
		w.Header().Add("Cache-Control", fmt.Sprintf("max-age=%d, public, must-revalidate, proxy-revalidate", w.maxAge))
	}
	w.ResponseWriter.WriteHeader(code)
}

func maxAgeHandler(maxAge time.Duration, h http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {