Documentation ¶
Overview ¶
Package common provides the ability to write a file with an eventual rename on Close (using os.Rename). This allows for a file to always be in a consistent state and never represent an in-progress write.
NOTE: `os.Rename` may not be atomic on your operating system.
Index ¶
Constants ¶
const (
RestSuccess = 0
)
Variables ¶
This section is empty.
Functions ¶
func ReadPid ¶
ReadPid the pid from the configured file. It is an error if the pidFile hasn't been configured.
func SavePid ¶
func SavePid(processConfig conf.ProcessConfig) error
SavePid save current process's pid into files.
Types ¶
type AtomicFile ¶
AtomicFile behaves like os.File, but does an atomic rename operation at Close.
func AtomicFileNew ¶
func AtomicFileNew(path string, mode os.FileMode) (*AtomicFile, error)
AtomicFileNew creates a new temporary file that will replace the file at the given path when Closed.
func (*AtomicFile) Abort ¶
func (f *AtomicFile) Abort() error
Abort closes the file and removes it instead of replacing the configured file. This is useful if after starting to write to the file you decide you don't want it anymore.
func (*AtomicFile) Close ¶
func (f *AtomicFile) Close() error
Close the file replacing the configured file.