Skip to content

Commit

Permalink
Merge pull request #188 from dshearer/docker-support
Browse files Browse the repository at this point in the history
Docker support
  • Loading branch information
dshearer committed Mar 25, 2018
2 parents 93d1a0e + 0ba7c54 commit a57feb6
Show file tree
Hide file tree
Showing 74 changed files with 3,472 additions and 2,512 deletions.
28 changes: 11 additions & 17 deletions Makefile
Expand Up @@ -20,6 +20,14 @@ GO_VERSION = 1.8

LDFLAGS = -ldflags "-X github.com/dshearer/jobber/common.jobberVersion=`cat version`"

PACKAGES = \
github.com/dshearer/jobber/common \
github.com/dshearer/jobber/ipc \
github.com/dshearer/jobber/jobber \
github.com/dshearer/jobber/jobbermaster \
github.com/dshearer/jobber/jobberrunner \
github.com/dshearer/jobber/jobfile

include mk/def-sources.mk

.PHONY : default
Expand All @@ -34,18 +42,8 @@ all : ${GO_WKSPC}/bin/jobber ${GO_WKSPC}/bin/jobbermaster \
.PHONY : check
check : ${TEST_SOURCES} jobfile/parse_time_spec.go
@go version
${GO} vet \
github.com/dshearer/jobber/common \
github.com/dshearer/jobber/jobber \
github.com/dshearer/jobber/jobbermaster \
github.com/dshearer/jobber/jobberrunner \
github.com/dshearer/jobber/jobfile
TMPDIR="${TEST_TMPDIR}" ${GO} test \
github.com/dshearer/jobber/common \
github.com/dshearer/jobber/jobber \
github.com/dshearer/jobber/jobbermaster \
github.com/dshearer/jobber/jobberrunner \
github.com/dshearer/jobber/jobfile
${GO} vet ${PACKAGES}
TMPDIR="${TEST_TMPDIR}" ${GO} test ${PACKAGES}

install : \
${DESTDIR}${libexecdir}/jobbermaster \
Expand Down Expand Up @@ -96,10 +94,6 @@ jobfile/parse_time_spec.go : ${GOYACC} ${JOBFILE_SOURCES}
.PHONY : clean
clean : clean-buildtools
@echo CLEAN
@-${GO} clean -i github.com/dshearer/jobber/common
@-${GO} clean -i github.com/dshearer/jobber/jobfile
@-${GO} clean -i github.com/dshearer/jobber/jobber
@-${GO} clean -i github.com/dshearer/jobber/jobbermaster
@-${GO} clean -i github.com/dshearer/jobber/jobberrunner
@-${GO} clean -i ${PACKAGES}
@rm -f "${DESTDIR}${SRC_TARBALL}.tgz" jobfile/parse_time_spec.go \
jobfile/y.output
102 changes: 0 additions & 102 deletions common/commands.go

This file was deleted.

9 changes: 2 additions & 7 deletions common/path.go
Expand Up @@ -9,9 +9,8 @@ import (
)

const (
VarDirPath = "/var/jobber"
CmdSocketFileName = "cmd.sock"
QuitSocketFileName = "quit.sock"
VarDirPath = "/var/jobber"
CmdSocketFileName = "cmd.sock"
)

var libexecPaths []string = []string{
Expand All @@ -27,10 +26,6 @@ func CmdSocketPath(usr *user.User) string {
return filepath.Join(PerUserDirPath(usr), CmdSocketFileName)
}

func QuitSocketPath(usr *user.User) string {
return filepath.Join(PerUserDirPath(usr), QuitSocketFileName)
}

/*
Get a list of all users for whom there is a jobberrunner process.
*/
Expand Down
1 change: 0 additions & 1 deletion common/sources.mk
Expand Up @@ -3,7 +3,6 @@ COMMON_SOURCES := \
common/error.go \
common/exec.go \
common/logging.go \
common/commands.go \
common/path.go \
common/sources.mk \
common/su_cmd_linux.go \
Expand Down
138 changes: 138 additions & 0 deletions ipc/commands.go
@@ -0,0 +1,138 @@
package ipc

import (
"time"

"github.com/dshearer/jobber/jobfile"
)

type ICmd interface{}

type ICmdResp interface {
Error() error
}

type errorCmdResp struct {
err error
}

func (self errorCmdResp) Error() error {
return self.err
}

func NewErrorCmdResp(err error) ICmdResp {
return errorCmdResp{err: err}
}

type nonErrorCmdResp struct{}

func (self nonErrorCmdResp) Error() error {
return nil
}

type ReloadCmd struct{}

type ReloadCmdResp struct {
NumJobs int `json:"numJobs"`
nonErrorCmdResp
}

type JobDesc struct {
Name string `json:"name"`
Status string `json:"status"`
Schedule string `json:"schedule"`
NextRunTime *time.Time `json:"nextRunTime"`
NotifyOnSuccess string `json:"notifyOnSuccess"`
NotifyOnErr string `json:"notifyOnError"`
NotifyOnFail string `json:"notifyOnFailure"`
ErrHandler string `json:"errHandler"`
StdoutDir *string `json:"stdoutDir"`
StderrDir *string `json:"stderrDir"`
}

type ListJobsCmd struct{}

type ListJobsCmdResp struct {
Jobs []JobDesc `json:"jobs"`
nonErrorCmdResp
}

type LogDesc struct {
Time time.Time `json:"time"`
Job string `json:"job"`
Succeeded bool `json:"succeeded"`
Result string `json:"result"`
}

type LogCmd struct{}

type LogCmdResp struct {
Logs []LogDesc `json:"logs"`
nonErrorCmdResp
}

type TestCmd struct {
Job string `json:"job"`
}

type TestCmdResp struct {
Result string `json:"result"`
nonErrorCmdResp
}

type CatCmd struct {
Job string `json:"job"`
}

type CatCmdResp struct {
Result string `json:"result"`
nonErrorCmdResp
}

type PauseCmd struct {
Jobs []string `json:"jobs"`
}

type PauseCmdResp struct {
NumPaused int `json:"numPaused"`
nonErrorCmdResp
}

type ResumeCmd struct {
Jobs []string `json:"jobs"`
}

type ResumeCmdResp struct {
NumResumed int `json:"numResumed"`
nonErrorCmdResp
}

type InitCmd struct{}

type InitCmdResp struct {
JobfilePath string `json:"jobfilePath"`
nonErrorCmdResp
}

type JobV3RawWithName struct {
jobfile.JobV3Raw
Name string
}

type SetJobCmd struct {
Job JobV3RawWithName `json:"job"`
}

type SetJobCmdResp struct {
Ok bool `json:"ok"` // just to make IPC work
nonErrorCmdResp
}

type DeleteJobCmd struct {
Job string `json:"job"`
}

type DeleteJobCmdResp struct {
Ok bool `json:"ok"` // just to make IPC work
nonErrorCmdResp
}
5 changes: 5 additions & 0 deletions ipc/sources.mk
@@ -0,0 +1,5 @@
IPC_SOURCES := \
ipc/commands.go \
ipc/sources.mk

IPC_TEST_SOURCES :=
9 changes: 5 additions & 4 deletions jobber/cmd_cat.go
Expand Up @@ -3,9 +3,10 @@ package main
import (
"flag"
"fmt"
"github.com/dshearer/jobber/common"
"os"
"os/user"

"github.com/dshearer/jobber/ipc"
)

func doCatCmd(args []string) int {
Expand Down Expand Up @@ -38,10 +39,10 @@ func doCatCmd(args []string) int {
}

// send command
var resp common.CatCmdResp
var resp ipc.CatCmdResp
err = CallDaemon(
"NewIpcService.Cat",
common.CatCmd{Job: job},
"IpcService.Cat",
ipc.CatCmd{Job: job},
&resp,
usr,
true,
Expand Down
13 changes: 5 additions & 8 deletions jobber/cmd_init.go
Expand Up @@ -3,9 +3,10 @@ package main
import (
"flag"
"fmt"
"github.com/dshearer/jobber/common"
"os"
"os/user"

"github.com/dshearer/jobber/ipc"
)

func doInitCmd(args []string) int {
Expand All @@ -30,10 +31,10 @@ func doInitCmd(args []string) int {
}

// send command
var resp common.InitCmdResp
var resp ipc.InitCmdResp
err = CallDaemon(
"NewIpcService.Init",
common.InitCmd{},
"IpcService.Init",
ipc.InitCmd{},
&resp,
usr,
true,
Expand All @@ -44,10 +45,6 @@ func doInitCmd(args []string) int {
}

// handle response
if resp.Err != nil {
fmt.Fprintf(os.Stderr, "%v\n", resp.Err)
return 1
}
fmt.Printf("You can now define jobs in %v.\n", resp.JobfilePath)
fmt.Println("Once you have done so, run 'jobber reload'.")
return 0
Expand Down

0 comments on commit a57feb6

Please sign in to comment.