cmd/hakurei: expose current instance identifier
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m25s
Test / Hakurei (push) Successful in 4m36s
Test / Sandbox (race detector) (push) Successful in 4m31s
Test / Hpkg (push) Successful in 4m52s
Test / Hakurei (race detector) (push) Successful in 6m4s
Test / Flake checks (push) Successful in 1m24s
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m25s
Test / Hakurei (push) Successful in 4m36s
Test / Sandbox (race detector) (push) Successful in 4m31s
Test / Hpkg (push) Successful in 4m52s
Test / Hakurei (race detector) (push) Successful in 6m4s
Test / Flake checks (push) Successful in 1m24s
This writes the 16-byte instance identifier to file descriptor specified by --identifier-fd if set, and closes the file. This enables safely obtaining the new instance's identifier. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -33,7 +33,7 @@ const (
|
||||
func NewStore(sc *hst.Paths) *store.Store { return store.New(sc.SharePath.Append("state")) }
|
||||
|
||||
// main carries out outcome and terminates. main does not return.
|
||||
func (k *outcome) main(msg message.Msg) {
|
||||
func (k *outcome) main(msg message.Msg, identifierFd int) {
|
||||
if k.ctx == nil || k.sys == nil || k.state == nil {
|
||||
panic("outcome: did not finalise")
|
||||
}
|
||||
@@ -163,6 +163,21 @@ func (k *outcome) main(msg message.Msg) {
|
||||
continue
|
||||
}
|
||||
|
||||
if f := os.NewFile(uintptr(identifierFd), "identifier"); f != nil {
|
||||
_, err = f.Write(k.state.id.v[:])
|
||||
if err != nil {
|
||||
unlock()
|
||||
// transition here to avoid the commit/revert cycle on the doomed instance
|
||||
perrorFatal(&hst.AppError{Step: "write instance identifier", Err: err},
|
||||
"write instance identifier", processLifecycle)
|
||||
continue
|
||||
}
|
||||
msg.Verbosef("wrote identifier to %d", identifierFd)
|
||||
if err = f.Close(); err != nil {
|
||||
msg.Verbose(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
err = k.sys.Commit()
|
||||
unlock()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user