本文整理汇总了Golang中github.com/coreos/rkt/pkg/log.NewLogSet函数的典型用法代码示例。如果您正苦于以下问题:Golang NewLogSet函数的具体用法?Golang NewLogSet怎么用?Golang NewLogSet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewLogSet函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
flag.BoolVar(&debug, "debug", false, "Run in debug mode")
flag.StringVar(&podPid, "pid", "", "podPID")
flag.StringVar(&appName, "appname", "", "application to use")
log, diag, _ = rktlog.NewLogSet("kvm", false)
}
示例2: main
func main() {
flag.Parse()
log, diag, _ = rktlog.NewLogSet("stage1 gc", debug)
if !debug {
diag.SetOutput(ioutil.Discard)
}
podID, err := types.NewUUID(flag.Arg(0))
if err != nil {
log.Fatal("UUID is missing or malformed")
}
diag.Printf("Removing journal link.")
if err := removeJournalLink(podID); err != nil {
log.PrintE("error removing journal link", err)
}
diag.Printf("Cleaning up cgroups.")
if err := cleanupV1Cgroups(); err != nil {
log.PrintE("error cleaning up cgroups", err)
}
diag.Printf("Tearing down networks.")
if err := gcNetworking(podID); err != nil {
log.FatalE("", err)
}
}
示例3: init
func init() {
flag.BoolVar(&debug, "debug", false, "Run in debug mode")
flag.StringVar(&podPid, "pid", "", "Pod PID")
flag.StringVar(&appName, "appname", "", "Application (Ignored in rkt fly)")
log, diag, _ = rktlog.NewLogSet("fly-enter", false)
}
示例4: main
func main() {
flag.Parse()
stage1initcommon.InitDebug(debug)
log, diag, _ = rktlog.NewLogSet("app-start", debug)
if !debug {
diag.SetOutput(ioutil.Discard)
}
appName, err := types.NewACName(flagApp)
if err != nil {
log.FatalE("invalid app name", err)
}
enterCmd := stage1common.PrepareEnterCmd(false)
args := enterCmd
args = append(args, "/usr/bin/systemctl")
args = append(args, "start")
args = append(args, appName.String())
cmd := exec.Cmd{
Path: args[0],
Args: args,
}
if out, err := cmd.CombinedOutput(); err != nil {
log.Fatalf("%q failed to start:\n%s", appName, out)
}
os.Exit(0)
}
示例5: ensureLogger
func ensureLogger(debug bool) {
if log == nil || diag == nil || stdout == nil {
log, diag, stdout = rktlog.NewLogSet("image", debug)
}
if !debug {
diag.SetOutput(ioutil.Discard)
}
}
示例6: main
func main() {
flag.Parse()
log, diag, _ = rktlog.NewLogSet("run", debug)
if !debug {
diag.SetOutput(ioutil.Discard)
}
// move code into stage1() helper so defered fns get run
os.Exit(stage1())
}
示例7: init
func init() {
flag.BoolVar(&debug, "debug", false, "Run in debug mode")
flag.StringVar(&podPid, "pid", "", "podPID")
flag.StringVar(&appName, "appname", "", "application to use")
log, diag, _ = rktlog.NewLogSet("kvm", false)
var err error
if sshPath, err = exec.LookPath("ssh"); err != nil {
log.FatalE("cannot find 'ssh' binary in PATH", err)
}
}
示例8: main
func main() {
rp := parseFlags()
stage1initcommon.InitDebug(debug)
log, diag, _ = rktlog.NewLogSet("stage1", debug)
if !debug {
diag.SetOutput(ioutil.Discard)
}
// move code into stage1() helper so deferred fns get run
os.Exit(stage1(rp))
}
示例9: main
// TODO use named flags instead of positional
func main() {
flag.Parse()
stage1initcommon.InitDebug(debug)
log, diag, _ = rktlog.NewLogSet("stage1", debug)
if !debug {
diag.SetOutput(ioutil.Discard)
}
appName, err := types.NewACName(flag.Arg(1))
if err != nil {
log.PrintE("invalid app name", err)
os.Exit(254)
}
enterEP := flag.Arg(2)
args := []string{enterEP}
args = append(args, fmt.Sprintf("--pid=%s", flag.Arg(3)))
args = append(args, "/usr/bin/systemctl")
args = append(args, "stop")
args = append(args, appName.String())
cmd := exec.Cmd{
Path: args[0],
Args: args,
}
if err := cmd.Run(); err != nil {
log.PrintE(fmt.Sprintf("error stopping app %q", appName.String()), err)
os.Exit(254)
}
os.Exit(0)
}
示例10: main
// TODO use named flags instead of positional
func main() {
flag.Parse()
stage1initcommon.InitDebug(debug)
log, diag, _ = rktlog.NewLogSet("stage1", debug)
if !debug {
diag.SetOutput(ioutil.Discard)
}
uuid, err := types.NewUUID(flag.Arg(0))
if err != nil {
log.PrintE("UUID is missing or malformed", err)
os.Exit(254)
}
appName, err := types.NewACName(flag.Arg(1))
if err != nil {
log.PrintE("invalid app name", err)
os.Exit(254)
}
enterEP := flag.Arg(2)
root := "."
p, err := stage1types.LoadPod(root, uuid)
if err != nil {
log.PrintE("failed to load pod", err)
os.Exit(254)
}
insecureOptions := stage1initcommon.Stage1InsecureOptions{
DisablePaths: disablePaths,
DisableCapabilities: disableCapabilities,
DisableSeccomp: disableSeccomp,
}
ra := p.Manifest.Apps.Get(*appName)
if ra == nil {
log.Printf("failed to get app")
os.Exit(254)
}
if ra.App.WorkingDirectory == "" {
ra.App.WorkingDirectory = "/"
}
binPath, err := stage1initcommon.FindBinPath(p, ra)
if err != nil {
log.PrintE("failed to find bin path", err)
os.Exit(254)
}
w := stage1initcommon.NewUnitWriter(p)
w.AppUnit(ra, binPath, privateUsers, insecureOptions,
unit.NewUnitOption("Unit", "Before", "halt.target"),
unit.NewUnitOption("Unit", "Conflicts", "halt.target"),
unit.NewUnitOption("Service", "StandardOutput", "journal+console"),
unit.NewUnitOption("Service", "StandardError", "journal+console"),
)
w.AppReaperUnit(ra.Name, binPath)
if err := w.Error(); err != nil {
log.PrintE("error generating app units", err)
os.Exit(254)
}
args := []string{enterEP}
args = append(args, fmt.Sprintf("--pid=%s", flag.Arg(3)))
args = append(args, "/usr/bin/systemctl")
args = append(args, "daemon-reload")
cmd := exec.Cmd{
Path: args[0],
Args: args,
}
if err := cmd.Run(); err != nil {
log.PrintE("error executing daemon-reload", err)
os.Exit(254)
}
args = []string{enterEP}
args = append(args, fmt.Sprintf("--pid=%s", flag.Arg(3)))
args = append(args, "/usr/bin/systemctl")
args = append(args, "start")
args = append(args, appName.String())
cmd = exec.Cmd{
Path: args[0],
Args: args,
}
if err := cmd.Run(); err != nil {
log.PrintE(fmt.Sprintf("error starting app %q", appName.String()), err)
//.........这里部分代码省略.........
示例11: main
// TODO use named flags instead of positional
func main() {
flag.Parse()
stage1initcommon.InitDebug(debug)
log, diag, _ = rktlog.NewLogSet("stage1", debug)
if !debug {
diag.SetOutput(ioutil.Discard)
}
appName, err := types.NewACName(flag.Arg(1))
if err != nil {
log.PrintE("invalid app name", err)
os.Exit(254)
}
enterEP := flag.Arg(2)
args := []string{enterEP}
args = append(args, fmt.Sprintf("--pid=%s", flag.Arg(3)))
args = append(args, "/usr/bin/systemctl")
args = append(args, "is-active")
args = append(args, appName.String())
cmd := exec.Cmd{
Path: args[0],
Args: args,
}
// rely only on the output, since it returns non-zero for inactive units
out, _ := cmd.Output()
if string(out) != "inactive\n" {
log.Printf("app %q is still running", appName.String())
os.Exit(254)
}
s1rootfs := common.Stage1RootfsPath(".")
serviceDir := filepath.Join(s1rootfs, "usr", "lib", "systemd", "system")
appServicePaths := []string{
filepath.Join(serviceDir, appName.String()+".service"),
filepath.Join(serviceDir, "reaper-"+appName.String()+".service"),
}
for _, p := range appServicePaths {
if err := os.Remove(p); err != nil && !os.IsNotExist(err) {
log.PrintE("error removing app service file", err)
os.Exit(254)
}
}
args = []string{enterEP}
args = append(args, fmt.Sprintf("--pid=%s", flag.Arg(3)))
args = append(args, "/usr/bin/systemctl")
args = append(args, "daemon-reload")
cmd = exec.Cmd{
Path: args[0],
Args: args,
}
if err := cmd.Run(); err != nil {
log.PrintE(`error executing "systemctl daemon-reload"`, err)
os.Exit(254)
}
// TODO unmount all the volumes
os.Exit(0)
}
示例12: main
func main() {
flag.Parse()
stage1initcommon.InitDebug(debug)
log, diag, _ = rktlog.NewLogSet("app-add", debug)
if !debug {
diag.SetOutput(ioutil.Discard)
}
uuid, err := types.NewUUID(flagUUID)
if err != nil {
log.FatalE("UUID is missing or malformed", err)
}
appName, err := types.NewACName(flagApp)
if err != nil {
log.FatalE("invalid app name", err)
}
root := "."
p, err := stage1types.LoadPod(root, uuid)
if err != nil {
log.FatalE("failed to load pod", err)
}
flavor, _, err := stage1initcommon.GetFlavor(p)
if err != nil {
log.FatalE("failed to get stage1 flavor", err)
}
insecureOptions := stage1initcommon.Stage1InsecureOptions{
DisablePaths: disablePaths,
DisableCapabilities: disableCapabilities,
DisableSeccomp: disableSeccomp,
}
ra := p.Manifest.Apps.Get(*appName)
if ra == nil {
log.Fatalf("failed to find app %q", *appName)
}
binPath, err := stage1initcommon.FindBinPath(p, ra)
if err != nil {
log.FatalE("failed to find bin path", err)
}
if ra.App.WorkingDirectory == "" {
ra.App.WorkingDirectory = "/"
}
enterCmd := stage1common.PrepareEnterCmd(false)
stage1initcommon.AppAddMounts(p, ra, enterCmd)
// when using host cgroups, make the subgroup writable by pod systemd
if flavor != "kvm" {
err = prepareAppCgroups(p, ra, enterCmd)
if err != nil {
log.FatalE("error preparing cgroups", err)
}
}
// write service files
w := stage1initcommon.NewUnitWriter(p)
w.AppUnit(ra, binPath, privateUsers, insecureOptions,
unit.NewUnitOption("Unit", "Before", "halt.target"),
unit.NewUnitOption("Unit", "Conflicts", "halt.target"),
unit.NewUnitOption("Service", "StandardOutput", "journal+console"),
unit.NewUnitOption("Service", "StandardError", "journal+console"),
)
w.AppReaperUnit(ra.Name, binPath)
if err := w.Error(); err != nil {
log.FatalE("error generating app units", err)
}
// stage2 environment is ready at this point, but systemd does not know
// about the new application yet
args := enterCmd
args = append(args, "/usr/bin/systemctl")
args = append(args, "daemon-reload")
cmd := exec.Cmd{
Path: args[0],
Args: args,
}
if out, err := cmd.CombinedOutput(); err != nil {
log.Fatalf("%q failed at daemon-reload:\n%s", appName, out)
}
os.Exit(0)
}
示例13: init
func init() {
log, diag, _ = rktlog.NewLogSet("stage1", false)
}