本文整理匯總了Golang中github.com/coreos/fleet/unit.UnitFile.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang UnitFile.String方法的具體用法?Golang UnitFile.String怎麽用?Golang UnitFile.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/coreos/fleet/unit.UnitFile
的用法示例。
在下文中一共展示了UnitFile.String方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: storeOrGetUnitFile
func (r *EtcdRegistry) storeOrGetUnitFile(u unit.UnitFile) (err error) {
um := unitModel{
Raw: u.String(),
}
val, err := marshal(um)
if err != nil {
return err
}
key := r.hashedUnitPath(u.Hash())
opts := &etcd.SetOptions{
PrevExist: etcd.PrevNoExist,
}
start := time.Now()
_, err = r.kAPI.Set(context.Background(), key, val, opts)
// unit is already stored
if isEtcdError(err, etcd.ErrorCodeNodeExist) {
// TODO(jonboulle): verify more here?
err = nil
}
if err != nil {
metrics.ReportRegistryOpFailure(metrics.Set)
return
}
metrics.ReportRegistryOpSuccess(metrics.Set, start)
return
}
示例2: Load
// Load writes the given Unit to disk, subscribing to relevant dbus
// events, caching the Unit's Hash, and, if necessary, instructing the systemd
// daemon to reload.
func (m *systemdUnitManager) Load(name string, u unit.UnitFile) error {
m.mutex.Lock()
defer m.mutex.Unlock()
err := m.writeUnit(name, u.String())
if err != nil {
return err
}
m.hashes[name] = u.Hash()
if m.unitRequiresDaemonReload(name) {
return m.daemonReload()
}
return nil
}
示例3: Load
// Load writes the given Unit to disk, subscribing to relevant dbus
// events and caching the Unit's Hash.
func (m *systemdUnitManager) Load(name string, u unit.UnitFile) error {
m.mutex.Lock()
defer m.mutex.Unlock()
err := m.writeUnit(name, u.String())
if err != nil {
return err
}
if _, exists := u.Contents["Install"]; exists {
log.Debugf("Detected [Install] section in the systemd unit (%s)", name)
ok, err := m.enableUnit(name)
if err != nil || !ok {
m.removeUnit(name)
return fmt.Errorf("Failed to enable systemd unit %s: %v", name, err)
}
}
m.hashes[name] = u.Hash()
return nil
}
示例4: storeOrGetUnitFile
func (r *EtcdRegistry) storeOrGetUnitFile(u unit.UnitFile) (err error) {
um := unitModel{
Raw: u.String(),
}
val, err := marshal(um)
if err != nil {
return err
}
key := r.hashedUnitPath(u.Hash())
opts := &etcd.SetOptions{
PrevExist: etcd.PrevNoExist,
}
_, err = r.kAPI.Set(r.ctx(), key, val, opts)
// unit is already stored
if isEtcdError(err, etcd.ErrorCodeNodeExist) {
// TODO(jonboulle): verify more here?
err = nil
}
return
}
示例5: storeOrGetUnitFile
func (r *EtcdRegistry) storeOrGetUnitFile(u unit.UnitFile) (err error) {
um := unitModel{
Raw: u.String(),
}
json, err := marshal(um)
if err != nil {
return err
}
req := etcd.Create{
Key: r.hashedUnitPath(u.Hash()),
Value: json,
}
_, err = r.etcd.Do(&req)
// unit is already stored
if err != nil && isNodeExist(err) {
// TODO(jonboulle): verify more here?
err = nil
}
return
}