wip: feat(task): defined concrete type for user group
wip: feat(version): added placeholder file + update gitignore wip: chore: removed unnecessary files
This commit is contained in:
parent
cdc66a2c22
commit
1926598c0f
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,3 @@
|
|||||||
/cmd/wingmate/wingmate
|
/cmd/wingmate/wingmate
|
||||||
/cmd/wingmate/version.txt
|
|
||||||
/cmd/pidproxy/pidproxy
|
/cmd/pidproxy/pidproxy
|
||||||
/cmd/exec/exec
|
/cmd/exec/exec
|
||||||
@ -3,7 +3,7 @@ all:
|
|||||||
go build -v
|
go build -v
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm version.txt
|
echo "dev" > version.txt
|
||||||
go clean -i -cache -testcache
|
go clean -i -cache -testcache
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
|||||||
1
cmd/wingmate/version.txt
Normal file
1
cmd/wingmate/version.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
dev
|
||||||
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"gitea.suyono.dev/suyono/wingmate"
|
"gitea.suyono.dev/suyono/wingmate"
|
||||||
@ -8,6 +9,11 @@ import (
|
|||||||
wminit "gitea.suyono.dev/suyono/wingmate/init"
|
wminit "gitea.suyono.dev/suyono/wingmate/init"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
//go:embed version.txt
|
||||||
|
version string
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
|
|||||||
@ -33,21 +33,23 @@ type Task struct {
|
|||||||
Setsid bool `mapstructure:"setsid"`
|
Setsid bool `mapstructure:"setsid"`
|
||||||
User string `mapstructure:"user"`
|
User string `mapstructure:"user"`
|
||||||
Group string `mapstructure:"group"`
|
Group string `mapstructure:"group"`
|
||||||
Background bool `mapstructure:"background"`
|
|
||||||
WorkingDir string `mapstructure:"working_dir"`
|
WorkingDir string `mapstructure:"working_dir"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServiceTask struct {
|
type ServiceTask struct {
|
||||||
Name string `mapstructure:"-"`
|
|
||||||
Task `mapstructure:",squash"`
|
Task `mapstructure:",squash"`
|
||||||
AutoStart bool `mapstructure:"autostart"`
|
Name string `mapstructure:"-"`
|
||||||
AutoRestart bool `mapstructure:"autorestart"`
|
Background bool `mapstructure:"background"`
|
||||||
|
PidFile string `mapstructure:"pidfile"`
|
||||||
|
StartSecs uint `mapstructure:"startsecs"`
|
||||||
|
AutoStart bool `mapstructure:"autostart"`
|
||||||
|
AutoRestart bool `mapstructure:"autorestart"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CronTask struct {
|
type CronTask struct {
|
||||||
Name string `mapstructure:"-"`
|
|
||||||
CronSchedule `mapstructure:"-"`
|
CronSchedule `mapstructure:"-"`
|
||||||
Task `mapstructure:",squash"`
|
Task `mapstructure:",squash"`
|
||||||
|
Name string `mapstructure:"-"`
|
||||||
Schedule string `mapstructure:"schedule"`
|
Schedule string `mapstructure:"schedule"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
package testconfig
|
|
||||||
|
|
||||||
var One = `service:
|
|
||||||
one:
|
|
||||||
command: "mycommand -o output"
|
|
||||||
two:
|
|
||||||
command: ["cmd", "now"]
|
|
||||||
workdir: /
|
|
||||||
`
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
service:
|
|
||||||
one:
|
|
||||||
command: "mycommand -o output"
|
|
||||||
two:
|
|
||||||
command: ["cmd", "now"]
|
|
||||||
workdir: /
|
|
||||||
@ -14,6 +14,8 @@ type Tasks interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UserGroup interface {
|
type UserGroup interface {
|
||||||
|
String() string
|
||||||
|
IsSet() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type TaskStatus interface {
|
type TaskStatus interface {
|
||||||
@ -37,6 +39,7 @@ type CronTask interface {
|
|||||||
type ServiceTask interface {
|
type ServiceTask interface {
|
||||||
Task
|
Task
|
||||||
Background() bool //NOTE: implies using wmpidproxy
|
Background() bool //NOTE: implies using wmpidproxy
|
||||||
|
PidFile() string //NOTE: implies using wmpidproxy
|
||||||
StartSecs() uint
|
StartSecs() uint
|
||||||
AutoStart() bool
|
AutoStart() bool
|
||||||
AutoRestart() bool
|
AutoRestart() bool
|
||||||
|
|||||||
@ -68,12 +68,11 @@ func (cms *CronMultiOccurrenceSpec) Match(u uint8) bool {
|
|||||||
|
|
||||||
type CronTask struct {
|
type CronTask struct {
|
||||||
CronSchedule
|
CronSchedule
|
||||||
|
userGroup
|
||||||
name string
|
name string
|
||||||
command []string
|
command []string
|
||||||
environ []string
|
environ []string
|
||||||
setsid bool
|
setsid bool
|
||||||
user string
|
|
||||||
group string
|
|
||||||
workingDir string
|
workingDir string
|
||||||
lastRun time.Time
|
lastRun time.Time
|
||||||
hasRun bool //NOTE: make sure initialised as false
|
hasRun bool //NOTE: make sure initialised as false
|
||||||
@ -144,8 +143,7 @@ func (c *CronTask) Setsid() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *CronTask) UserGroup() wminit.UserGroup {
|
func (c *CronTask) UserGroup() wminit.UserGroup {
|
||||||
panic("not implemented")
|
return &(c.userGroup)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CronTask) WorkingDir() string {
|
func (c *CronTask) WorkingDir() string {
|
||||||
|
|||||||
29
task/task.go
29
task/task.go
@ -1,6 +1,7 @@
|
|||||||
package task
|
package task
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
wminit "gitea.suyono.dev/suyono/wingmate/init"
|
wminit "gitea.suyono.dev/suyono/wingmate/init"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -63,11 +64,10 @@ type ServiceTask struct {
|
|||||||
command []string
|
command []string
|
||||||
environ []string
|
environ []string
|
||||||
setsid bool
|
setsid bool
|
||||||
user string
|
|
||||||
group string
|
|
||||||
background bool
|
background bool
|
||||||
workingDir string
|
workingDir string
|
||||||
startSecs uint
|
startSecs uint
|
||||||
|
userGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServiceTask(name string) *ServiceTask {
|
func NewServiceTask(name string) *ServiceTask {
|
||||||
@ -139,8 +139,7 @@ func (t *ServiceTask) Setsid() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *ServiceTask) UserGroup() wminit.UserGroup {
|
func (t *ServiceTask) UserGroup() wminit.UserGroup {
|
||||||
panic("not implemented")
|
return &(t.userGroup)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *ServiceTask) Background() bool {
|
func (t *ServiceTask) Background() bool {
|
||||||
@ -172,3 +171,25 @@ func (t *ServiceTask) StartSecs() uint {
|
|||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *ServiceTask) PidFile() string {
|
||||||
|
panic("not implemented")
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type userGroup struct {
|
||||||
|
user string
|
||||||
|
group string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ug *userGroup) IsSet() bool {
|
||||||
|
return len(ug.user) > 0 || len(ug.group) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ug *userGroup) String() string {
|
||||||
|
if len(ug.group) > 0 {
|
||||||
|
return fmt.Sprintf("%s:%s", ug.user, ug.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ug.user
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user