// Init initialize the sandbox environment
//export Init
Init initialize the sandbox environment
export Init
// Init initialize the sandbox environment // export Init
func Init(i *C.char) C.int {
	is := C.GoString(i)
	var ip initParameter
	if err := json.NewDecoder(bytes.NewBufferString(is)).Decode(&ip); err != nil {
		return -1
	}
	if ip.Parallelism == 0 {
		ip.Parallelism = 4
	}
	if ip.TmpFsParam == "" {
		ip.TmpFsParam = "size=16m,nr_inodes=4k"
	}
	if ip.MountConf == "" {
		ip.MountConf = "mount.yaml"
	}
	srcPrefix = ip.SrcPrefix
	fs = newFilsStore(ip.Dir)
	b, err := env.NewBuilder(env.Config{
		ContainerInitPath:  ip.CInitPath,
		MountConf:          ip.MountConf,
		TmpFsParam:         ip.TmpFsParam,
		NetShare:           ip.NetShare,
		CgroupPrefix:       ip.CgroupPrefix,
		Cpuset:             ip.CPUSet,
		ContainerCredStart: ip.CredStart,
		Logger:             nopLogger{},
	})
	if err != nil {
		log.Fatalln("create environment builder failed", err)
	}
	envPool := pool.NewPool(b)
	work = worker.New(worker.Config{
		FileStore:             fs,
		EnvironmentPool:       envPool,
		Parallelism:           ip.Parallelism,
		WorkDir:               ip.Dir,
		TimeLimitTickInterval: 100 * time.Millisecond,
	})
	work.Start()
	return 0
}
func Init ( i * C . char ) C . int { is := C . GoString ( i ) var ip initParameter if err := json . NewDecoder ( bytes . NewBufferString ( is ) ) . Decode ( & ip ) ; err != nil { return - 1 } if ip . Parallelism == 0 { ip . Parallelism = 4 } if ip . TmpFsParam == " " { ip . TmpFsParam = " " } if ip . MountConf == " " { ip . MountConf = " " } srcPrefix = ip . SrcPrefix fs = newFilsStore ( ip . Dir ) b , err := env . NewBuilder ( env . Config { ContainerInitPath : ip . CInitPath , MountConf : ip . MountConf , TmpFsParam : ip . TmpFsParam , NetShare : ip . NetShare , CgroupPrefix : ip . CgroupPrefix , Cpuset : ip . CPUSet , ContainerCredStart : ip . CredStart , Logger : nopLogger { } , } ) if err != nil { log . Fatalln ( " " , err ) } envPool := pool . NewPool ( b ) work = worker . New ( worker . Config { FileStore : fs , EnvironmentPool : envPool , Parallelism : ip . Parallelism , WorkDir : ip . Dir , TimeLimitTickInterval : 100 * time . Millisecond , } ) work . Start ( ) return 0 }
Init initialize the sandbox environment
export Init
Init initialize the sandbox environment export Init