MCPcopy
hub / github.com/tuna/tunasync / Do

Method Do

worker/exec_post_hook.go:61–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59}
60
61func (h *execPostHook) Do() error {
62 p := h.provider
63
64 exitStatus := ""
65 if h.execOn == execOnSuccess {
66 exitStatus = "success"
67 } else {
68 exitStatus = "failure"
69 }
70
71 env := map[string]string{
72 "TUNASYNC_MIRROR_NAME": p.Name(),
73 "TUNASYNC_WORKING_DIR": p.WorkingDir(),
74 "TUNASYNC_UPSTREAM_URL": p.Upstream(),
75 "TUNASYNC_LOG_DIR": p.LogDir(),
76 "TUNASYNC_LOG_FILE": p.LogFile(),
77 "TUNASYNC_JOB_EXIT_STATUS": exitStatus,
78 }
79
80 session := sh.NewSession()
81 for k, v := range env {
82 session.SetEnv(k, v)
83 }
84
85 var cmd string
86 args := []interface{}{}
87 if len(h.command) == 1 {
88 cmd = h.command[0]
89 } else if len(h.command) > 1 {
90 cmd = h.command[0]
91 for _, arg := range h.command[1:] {
92 args = append(args, arg)
93 }
94 } else {
95 return errors.New("Invalid Command")
96 }
97 return session.Command(cmd, args...).Run()
98}

Callers 5

postSuccessMethod · 0.95
postFailMethod · 0.95
removeWorkerFunction · 0.80
flushDisabledJobsFunction · 0.80
TestHTTPServerFunction · 0.80

Calls 6

NameMethod · 0.65
WorkingDirMethod · 0.65
UpstreamMethod · 0.65
LogDirMethod · 0.65
LogFileMethod · 0.65
RunMethod · 0.65

Tested by 1

TestHTTPServerFunction · 0.64