preparation for v0.2.0 #3
@ -23,6 +23,36 @@ type Config struct {
|
|||||||
Cron []*Cron
|
Cron []*Cron
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Task struct {
|
||||||
|
Command []string `yaml:"command"`
|
||||||
|
Environ []string `yaml:"environ"`
|
||||||
|
Setsid bool `yaml:"setsid"`
|
||||||
|
User string `yaml:"user"`
|
||||||
|
Group string `yaml:"group"`
|
||||||
|
Background bool `yaml:"background"`
|
||||||
|
WorkingDir string `yaml:"working_dir"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ServiceTask struct {
|
||||||
|
Task `yaml:",inline"`
|
||||||
|
AutoStart bool `yaml:"autostart"`
|
||||||
|
AutoRestart bool `yaml:"autorestart"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CronTask struct {
|
||||||
|
CronSchedule `yaml:"-"`
|
||||||
|
Task `yaml:",inline"`
|
||||||
|
Schedule string `yaml:"schedule"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CronSchedule struct {
|
||||||
|
Minute CronTimeSpec
|
||||||
|
Hour CronTimeSpec
|
||||||
|
DoM CronTimeSpec
|
||||||
|
Month CronTimeSpec
|
||||||
|
DoW CronTimeSpec
|
||||||
|
}
|
||||||
|
|
||||||
func Read() (*Config, error) {
|
func Read() (*Config, error) {
|
||||||
viper.SetEnvPrefix(EnvPrefix)
|
viper.SetEnvPrefix(EnvPrefix)
|
||||||
viper.BindEnv(EnvConfigPath)
|
viper.BindEnv(EnvConfigPath)
|
||||||
|
|||||||
1
config/yaml.go
Normal file
1
config/yaml.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package config
|
||||||
24
task/task.go
24
task/task.go
@ -17,7 +17,7 @@ func NewTasks() *Tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ts *Tasks) AddV0Service(path string) {
|
func (ts *Tasks) AddV0Service(path string) {
|
||||||
ts.services = append(ts.services, &Task{
|
ts.services = append(ts.services, &ServiceTask{
|
||||||
name: path,
|
name: path,
|
||||||
command: []string{path},
|
command: []string{path},
|
||||||
})
|
})
|
||||||
@ -56,57 +56,57 @@ func (ts *Tasks) Get(name string) (wminit.Task, error) {
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type Task struct {
|
type ServiceTask struct {
|
||||||
name string
|
name string
|
||||||
command []string
|
command []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Name() string {
|
func (t *ServiceTask) Name() string {
|
||||||
return t.name
|
return t.name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Command() []string {
|
func (t *ServiceTask) Command() []string {
|
||||||
retval := make([]string, len(t.command))
|
retval := make([]string, len(t.command))
|
||||||
copy(retval, t.command)
|
copy(retval, t.command)
|
||||||
return retval
|
return retval
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Environ() []string {
|
func (t *ServiceTask) Environ() []string {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Setsid() bool {
|
func (t *ServiceTask) Setsid() bool {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) UserGroup() wminit.UserGroup {
|
func (t *ServiceTask) UserGroup() wminit.UserGroup {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Background() bool {
|
func (t *ServiceTask) Background() bool {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) WorkingDir() string {
|
func (t *ServiceTask) WorkingDir() string {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Status() wminit.TaskStatus {
|
func (t *ServiceTask) Status() wminit.TaskStatus {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) AutoStart() bool {
|
func (t *ServiceTask) AutoStart() bool {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) AutoRestart() bool {
|
func (t *ServiceTask) AutoRestart() bool {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,11 +33,11 @@ func TestCronV0(t *testing.T) {
|
|||||||
func TestTasks_List(t *testing.T) {
|
func TestTasks_List(t *testing.T) {
|
||||||
tasks := NewTasks()
|
tasks := NewTasks()
|
||||||
tasks.services = []wminit.ServiceTask{
|
tasks.services = []wminit.ServiceTask{
|
||||||
&Task{
|
&ServiceTask{
|
||||||
name: "one",
|
name: "one",
|
||||||
command: []string{"/path/to/executable"},
|
command: []string{"/path/to/executable"},
|
||||||
},
|
},
|
||||||
&Task{
|
&ServiceTask{
|
||||||
name: "two",
|
name: "two",
|
||||||
command: []string{"/path/to/executable"},
|
command: []string{"/path/to/executable"},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user