Ejemplo n.º 1
0
func (h *ImageProcessHandler) recUrlEvt(c cat.Cat, imagePath string, r *http.Request) {
	util.LogEvent(c, "URL", "URL.Method", map[string]string{
		"Http": fmt.Sprintf("%s %s", r.Method, imagePath),
	})

	util.LogEvent(c, "image", fmt.Sprintf("%s:%d", util.LocalIP(), h.listenPort), nil)

	util.LogEvent(c, "URL", "URL.Client", map[string]string{
		"clientip": util.HttpClietIP(r),
		"serverip": util.LocalIP(),
		"proto":    r.Proto,
		"referer":  r.Referer(),
	})
}
Ejemplo n.º 2
0
func (w *ImageProcessWorker) Start(opt StartOpt) <-chan error {
	if !opt.NewHosting {
		opts := &web.ImageProcessOptions{ListenAddress: fmt.Sprintf("127.0.0.1:%d", w.Port)}
		webHandler := web.NewImageProcessWebHandler(opts)
		util.LogEvent(cat.Instance(), "Reboot", fmt.Sprintf("%s:%d", util.LocalIP(), w.Port), nil)
		go webHandler.Run()
		return webHandler.ListenError()
	} else {
		cmd := exec.Command("go", "run", "imgsvrd.go", "-process.worker", "-port", strconv.Itoa(w.Port))
		err := cmd.Start()
		if err != nil {
			log.Errorf("start worker=%d failed. error=%s", w.Port, err.Error())
			util.LogErrorEvent(cat.Instance(), "DaemonProcess.StartWorkerError", err.Error())
			w.startErrCh <- err
		}
	}
	return w.startErrCh
}