small changes and force run for release

master
bel 2020-03-16 04:50:09 +00:00
parent 9ec88a5ce8
commit 13edf77b08
6 changed files with 86 additions and 4 deletions

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
vendor
**/*.sw*

23
Dockerfile Executable file
View File

@ -0,0 +1,23 @@
FROM frolvlad/alpine-glibc:alpine-3.11_glibc-2.30
RUN apk update \
&& apk add --no-cache \
ca-certificates \
bash \
jq \
python3 \
curl \
&& apk add --no-cache tzdata \
&& cp /usr/share/zoneinfo/America/Denver /etc/localtime \
&& echo "America/Denver" > /etc/timezone
RUN mkdir -p /var/log
WORKDIR /main
COPY . .
ENV GOPATH=""
ENV MNT="/mnt/"
ENTRYPOINT ["/main/firestormy"]
CMD []

View File

@ -11,12 +11,14 @@
x job title includes last pass/fail icon
x button to modify (copies to upsert form)
x button to delete
1. last run with title
1. word wrap or truncate output
1. UI to mutate
1. force run
x submit job
x delete job
x pause jobs
1. interrupt job
1. force run
x JS
x ajax for json calls
@ -25,6 +27,7 @@ x JS
x load from file
1. interrupt running jobs
1. json API
1. force run
1. list
x last run output
x last run pass/fail bool
@ -35,7 +38,6 @@ x load from file
x disable job
1. running job
1. interrupt job
1. force run
1. change cron to load the full job from storage so not holding big queued jobs in ram
x add optional second for test main
1. test main

View File

@ -57,8 +57,7 @@ function format(job) {
var buttons = ""
var btns = [
{"name":"refresh", "icon":"8635"},
{"name":"disable", "icon":"11035"},
{"name":"enable", "icon":"9654"},
{"name":"run", "icon":"9654"},
{"name":"modify", "icon":"9999"},
{"name":"delete", "icon":"10006"}
]
@ -118,6 +117,16 @@ function jobenable(input) {
getField("disabled").checked = false
}
function jobrun(input) {
var job = jobFromInput(input)
function cb(body, status) {
if (status != 200) {
console.log("failed to run job: ", status, body)
}
}
http("GET", "/api/job/run/"+job.id, cb, null)
}
function jobmodify(input) {
var form = getForm()
var job = jobFromInput(input)

View File

@ -36,6 +36,10 @@ func (s *Server) Routes() error {
path: fmt.Sprintf("/api/job/enable/%s", router.Wildcard),
handler: s.gzip(s.authenticate(s.enable)),
},
{
path: fmt.Sprintf("/api/job/run/%s", router.Wildcard),
handler: s.gzip(s.authenticate(s.run)),
},
{
path: fmt.Sprintf("%s%s", wildcard, wildcard),
handler: s.gzip(s.authenticate(s.static)),

42
server/run.go Normal file
View File

@ -0,0 +1,42 @@
package server
import (
"local/firestormy/config"
"local/firestormy/config/ns"
"local/firestormy/scheduler"
"net/http"
"strings"
)
func (s *Server) run(w http.ResponseWriter, r *http.Request) {
keys := strings.Split(r.URL.Path, "/")
key := keys[len(keys)-1]
j := &scheduler.Job{}
b, err := config.Store.Get(key, ns.Jobs...)
if err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
if err := j.Decode(b); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
func() {
defer func() {
if e := recover(); e != nil {
if er, ok := e.(error); ok {
err = er
}
}
}()
j.Run()
}()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Write([]byte("{}"))
}