本文整理汇总了Golang中github.com/juju/juju/service/common.Conf.AfterStopped方法的典型用法代码示例。如果您正苦于以下问题:Golang Conf.AfterStopped方法的具体用法?Golang Conf.AfterStopped怎么用?Golang Conf.AfterStopped使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/service/common.Conf
的用法示例。
在下文中一共展示了Conf.AfterStopped方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: shutdownInitCommands
func shutdownInitCommands(initSystem, series string) ([]string, error) {
shutdownCmd := "/sbin/shutdown -h now"
name := "juju-template-restart"
desc := "juju shutdown job"
execStart := shutdownCmd
conf := common.Conf{
Desc: desc,
Transient: true,
AfterStopped: "cloud-final",
ExecStart: execStart,
}
// systemd uses targets for synchronization of services
if initSystem == service.InitSystemSystemd {
conf.AfterStopped = "cloud-config.target"
}
svc, err := service.NewService(name, conf, series)
if err != nil {
return nil, errors.Trace(err)
}
cmds, err := svc.InstallCommands()
if err != nil {
return nil, errors.Trace(err)
}
startCommands, err := svc.StartCommands()
if err != nil {
return nil, errors.Trace(err)
}
cmds = append(cmds, startCommands...)
return cmds, nil
}
示例2: shutdownInitCommands
func shutdownInitCommands(initSystem, series string) ([]string, error) {
// These files are removed just before the template shuts down.
cleanupOnShutdown := []string{
// We remove any dhclient lease files so there's no chance a
// clone to reuse a lease from the template it was cloned
// from.
"/var/lib/dhcp/dhclient*",
// Both of these sets of files below are recreated on boot and
// if we leave them in the template's rootfs boot logs coming
// from cloned containers will be appended. It's better to
// keep clean logs for diagnosing issues / debugging.
"/var/log/cloud-init*.log",
}
// Using EOC below as the template shutdown script is itself
// passed through cat > ... < EOF.
replaceNetConfCmd := fmt.Sprintf(
"/bin/cat > /etc/network/interfaces << EOC%sEOC\n ",
defaultEtcNetworkInterfaces,
)
paths := strings.Join(cleanupOnShutdown, " ")
removeCmd := fmt.Sprintf("/bin/rm -fr %s\n ", paths)
shutdownCmd := "/sbin/shutdown -h now"
name := "juju-template-restart"
desc := "juju shutdown job"
execStart := shutdownCmd
if environs.AddressAllocationEnabled() {
// Only do the cleanup and replacement of /e/n/i when address
// allocation feature flag is enabled.
execStart = replaceNetConfCmd + removeCmd + shutdownCmd
}
conf := common.Conf{
Desc: desc,
Transient: true,
AfterStopped: "cloud-final",
ExecStart: execStart,
}
// systemd uses targets for synchronization of services
if initSystem == service.InitSystemSystemd {
conf.AfterStopped = "cloud-config.target"
}
svc, err := service.NewService(name, conf, series)
if err != nil {
return nil, errors.Trace(err)
}
cmds, err := svc.InstallCommands()
if err != nil {
return nil, errors.Trace(err)
}
startCommands, err := svc.StartCommands()
if err != nil {
return nil, errors.Trace(err)
}
cmds = append(cmds, startCommands...)
return cmds, nil
}