// Load writes the given Unit to disk, subscribing to relevant dbus // events, and, if necessary, instructing the systemd daemon to reload. func (m *SystemdUnitManager) Load(name string, u unit.Unit) error { err := m.writeUnit(name, u.String()) if err != nil { return err } m.subscriptions.Add(name) return m.daemonReload() }
// 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.Unit) error { m.mutex.Lock() defer m.mutex.Unlock() err := m.writeUnit(name, u.String()) if err != nil { return err } m.hashes[name] = u.Hash() return m.daemonReload() }
func (r *EtcdRegistry) storeOrGetUnit(u unit.Unit) (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 }