1/*
2 * Copyright (c) 2016-2017, Randy Westlund. All rights reserved.
3 * This code is under the BSD-2-Clause license.
4 *
5 * This file contains struct definitions.
6 */
7
8package main
9
10import (
11	"time"
12)
13
14// The status object returned from launching a child in a goroutine.
15type launchStatus struct {
16	Name string
17	Pid  int
18	// If the process failed for any reason, that reason is here.
19	Err error
20	// The duration for which the process ran.
21	Duration time.Duration
22}
23
24type process struct {
25	// The process config object from the config file.
26	Config processConfig
27	// The most recent launch status.
28	Status launchStatus
29	// Whether it's currently running or not.
30	Running bool
31}
32
33// A process definition, as read directly from the config file.
34type processConfig struct {
35	// A human-readable tag for process.
36	Name string
37	// The path to the actual executable to run.
38	Path string
39	// An array of string arguments to be passed to the process.
40	Args []string
41	// The cwd of the process. Defaults to /var/empty.
42	Cwd string
43	// Filenames for writing stdout and stderr. Defaults to /dev/null.
44	Stdout string
45	Stderr string
46	// The number of milliseconds to wait before restarting a process.
47	RestartDelay uint64 `toml:"restart_delay"`
48	// Whether to disable restarting on failure.
49	IgnoreFailure bool `toml:"ignore_failure"`
50	// If a process exits within this many milliseconds, don't restart it. A
51	// value of 0 disables this check.
52	MinRuntime  int      `toml:"min_runtime"`
53	SoftDepends []string `toml:"soft_depends"`
54	User        string
55	Group       string
56}
57
58// The config file definition.
59type configOptions struct {
60	// This must be named after the [[process]] block in the config file.
61	Process []processConfig
62	// Where to send paladin's logging output. Defaults to stderr.
63	LogFile string `toml:"log_file"`
64}
65