Beispiel #1
0
func (cm *CacheMonitor) reloadFile(source1, source2, dest string) error {
	// Create the destination directory if it does not exist.
	fpath, _ := path.Split(dest)
	_, err := os.Stat(fpath)
	if os.IsNotExist(err) {
		err = os.MkdirAll(fpath, 0744)
		if err != nil {
			return err
		}
	} else if err != nil {
		return err
	}

	proc, err := osutil.RunWithEnv(
		"framework/merge-handlers/"+cm.typ,
		nil,
		[]string{
			"WFDR_SOURCE_1=" + source1,
			"WFDR_SOURCE_2=" + source2,
			"WFDR_DEST=" + dest,
		})
	if err != nil {
		return errors.New(fmt.Sprintln("Failed to run command", cm.typ, ":", err))
	}
	proc.Wait()
	return nil
}
Beispiel #2
0
func (v *Visitor) ReloadFile(layout string) {
	cmd := ""
	switch v.fileType {
	case "css", "js", "img", "tmpl":
		cmd = v.fileType
	default:
		fmt.Println("WARNING: UNRECOGNIZED FILE TYPE", v.fileType)
	}

	source1 := v.source.JoinWithLayout("base")
	source2 := v.source.JoinWithLayout(layout)
	dest := v.source.JoinWithRootLayoutAndSubfolder(v.dest.root, layout, v.dest.subfolder)

	dlog.Println("Calculated destination as:", dest)

	proc, err := osutil.RunWithEnv(
		"framework/merge-handlers/"+cmd,
		nil,
		[]string{
			"WFDR_SOURCE_1=" + source1,
			"WFDR_SOURCE_2=" + source2,
			"WFDR_DEST=" + dest,
		})
	if err != nil {
		log.Println("Failed to run command", cmd, ":", err)
		return
	}
	proc.Wait()
}
Beispiel #3
0
func StartSync(moddir, jaildir, modname string) (*os.Process, error) {
	//hho := exec.PassThrough
	deamon, err := osutil.RunWithEnv("jail-deamon", nil, []string{"WFDR_MODDIR=" + moddir, "WFDR_JAILDIR=" + jaildir, "WFDR_MODNAME=" + modname})
	if err != nil {
		return nil, errors.New(fmt.Sprint("Could not start sync deamon, css, js, and template files will not be synced:", err))
	}
	return deamon.Process, nil
}
Beispiel #4
0
func JailInit(moddir, jaildir, modname string) error {
	osutil.WaitRun("wfdr-reload-shared", nil)
	setup, err := osutil.RunWithEnv("jail-init", nil, []string{"WFDR_MODDIR=" + moddir, "WFDR_JAILDIR=" + jaildir, "WFDR_MODNAME=" + modname})
	if err != nil {
		return errors.New(fmt.Sprint("Could not run script to initialize jail:", err, " PATH:", os.Getenv("PATH")))
	}
	setup.Wait()
	return nil
}