Move cron to drupal page

This commit is contained in:
Tom Wiesing 2023-11-10 20:23:55 +01:00
parent 7c544d9ae4
commit 7fefb689c7
No known key found for this signature in database
9 changed files with 61 additions and 41 deletions

10
go.mod
View file

@ -8,15 +8,15 @@ require (
github.com/compose-spec/compose-go v1.20.0
github.com/docker/docker v24.0.7+incompatible
github.com/gliderlabs/ssh v0.3.5
github.com/gorilla/csrf v1.7.1
github.com/gorilla/csrf v1.7.2
github.com/gorilla/sessions v1.2.1
github.com/gorilla/websocket v1.5.0
github.com/gorilla/websocket v1.5.1
github.com/julienschmidt/httprouter v1.3.0
github.com/pkg/errors v0.9.1
github.com/pquerna/otp v1.4.0
github.com/rs/zerolog v1.31.0
github.com/tkw1536/goprogram v0.5.0
github.com/tkw1536/pkglib v0.0.0-20231102105724-b30af08a5e61
github.com/tkw1536/pkglib v0.0.0-20231110192201-b920fd9f7764
github.com/yuin/goldmark v1.6.0
github.com/yuin/goldmark-meta v1.1.0
golang.org/x/crypto v0.14.0
@ -41,7 +41,7 @@ require (
github.com/feiin/sqlstring v0.3.0 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
github.com/gosuri/uilive v0.0.4 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/jessevdk/go-flags v1.5.0 // indirect
@ -64,7 +64,7 @@ require (
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.14.0 // indirect

21
go.sum
View file

@ -42,14 +42,17 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/gorilla/csrf v1.7.1 h1:Ir3o2c1/Uzj6FBxMlAUB6SivgVMy1ONXwYgXn+/aHPE=
github.com/gorilla/csrf v1.7.1/go.mod h1:+a/4tCmqhG6/w4oafeAZ9pEa3/NZOWYVbD9fV0FwIQA=
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/gorilla/csrf v1.7.2 h1:oTUjx0vyf2T+wkrx09Trsev1TE+/EbDAeHtSTbtC2eI=
github.com/gorilla/csrf v1.7.2/go.mod h1:F1Fj3KG23WYHE6gozCmBAezKookxbIvUJT+121wTuLk=
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI=
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/gosuri/uilive v0.0.4 h1:hUEBpQDj8D8jXgtCdBu7sWsy5sbW/5GhuO8KBwJ2jyY=
github.com/gosuri/uilive v0.0.4/go.mod h1:V/epo5LjjlDE5RJUcqx8dbw+zc93y5Ya3yg8tfZ74VI=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
@ -117,8 +120,8 @@ github.com/tdewolff/test v1.0.7 h1:8Vs0142DmPFW/bQeHRP3MV19m1gvndjUb1sn8yy74LM=
github.com/tdewolff/test v1.0.7/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
github.com/tkw1536/goprogram v0.5.0 h1:7vcIjmMdcZPJyRhgdlCaGfHAoOG3oYlFrno1pWXy1Bs=
github.com/tkw1536/goprogram v0.5.0/go.mod h1:MDCwqLmvcc2QryMm6oSC9h/QAdE9PewZ2Mp2Lm7MmAg=
github.com/tkw1536/pkglib v0.0.0-20231102105724-b30af08a5e61 h1:kj2iTWUtfXyeiK7CoGsd0wBof+Py6pXvDUI7aDZaZIc=
github.com/tkw1536/pkglib v0.0.0-20231102105724-b30af08a5e61/go.mod h1:vbJxEej2lPJXsFUxTGPK+nREnQOOyiBGdWL0kuzpsDQ=
github.com/tkw1536/pkglib v0.0.0-20231110192201-b920fd9f7764 h1:rJStxc6PoFUQcsRRqoUNtaM80GZWT69WfWeA+EDbvXM=
github.com/tkw1536/pkglib v0.0.0-20231110192201-b920fd9f7764/go.mod h1:Qi/vpuxuxo5D40O9jLUSmcUF01B5LmJqDxs8o8Lc6bg=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
@ -170,8 +173,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=

View file

@ -211,16 +211,7 @@
<tr>
<td>
Last Rebuild <br>
<a class="pure-button" href="/admin/rebuild/{{ .Info.Slug }}">Rebuild</button>
</td>
<td>
<code class="date">{{ .Info.LastRebuild.Format "2006-01-02T15:04:05Z07:00" }}</code>
</td>
</tr>
<tr>
<td>
Last Cron<br>
<button class="remote-action pure-button pure-button-action" data-action="cron" data-param="{{ .Instance.Slug }}" data-buffer="1000" data-force-reload>Cron</button>
<a class="pure-button" href="/admin/instance/{{ .Info.Slug }}/rebuild">Rebuild</button>
</td>
<td>
<code class="date">{{ .Info.LastRebuild.Format "2006-01-02T15:04:05Z07:00" }}</code>

View file

@ -30,6 +30,15 @@
<code>{{ .DefaultTheme }}</code>
</td>
</tr>
<tr>
<td>
Last Cron<br>
<button class="remote-action pure-button pure-button-action" data-action="cron" data-param="{{ .Instance.Slug }}" data-buffer="1000" data-force-reload>Cron</button>
</td>
<td>
<code class="date">{{ .LastCron.Format "2006-01-02T15:04:05Z07:00" }}</code>
</td>
</tr>
</tbody>
</table>
</div>

View file

@ -5,6 +5,7 @@ import (
_ "embed"
"html/template"
"net/http"
"time"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/server/assets"
@ -12,6 +13,7 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/status"
"github.com/FAU-CDI/wisski-distillery/internal/wisski"
"github.com/tkw1536/pkglib/httpx"
"golang.org/x/sync/errgroup"
"github.com/julienschmidt/httprouter"
)
@ -33,6 +35,8 @@ type instanceDrupalContext struct {
DefaultTheme string
Requirements []status.Requirement
LastCron time.Time
}
func (admin *Admin) instanceDrupal(ctx context.Context) http.Handler {
@ -55,24 +59,33 @@ func (admin *Admin) instanceDrupal(ctx context.Context) http.Handler {
return ctx, nil, httpx.ErrNotFound
}
server := ctx.Instance.PHP().NewServer()
defer server.Close()
var eg errgroup.Group
// get the requirements
ctx.Requirements, err = ctx.Instance.Requirements().Get(r.Context(), server)
if err != nil {
return ctx, nil, httpx.ErrInternalServerError
}
eg.Go(func() (err error) {
ctx.Requirements, err = ctx.Instance.Requirements().Get(r.Context(), nil)
return
})
// get the drupal version
ctx.DrupalVersion, err = ctx.Instance.Version().Get(r.Context(), server)
if err != nil {
return ctx, nil, httpx.ErrInternalServerError
}
eg.Go(func() (err error) {
ctx.DrupalVersion, err = ctx.Instance.Version().Get(r.Context(), nil)
return
})
// get the default theme
ctx.DefaultTheme, err = ctx.Instance.Theme().Get(r.Context(), server)
if err != nil {
eg.Go(func() (err error) {
ctx.DefaultTheme, err = ctx.Instance.Theme().Get(r.Context(), nil)
return
})
// last time cron was executed
eg.Go(func() (err error) {
ctx.LastCron, err = ctx.Instance.Drush().LastCron(r.Context(), nil)
return
})
if err = eg.Wait(); err != nil {
return ctx, nil, httpx.ErrInternalServerError
}

View file

@ -143,7 +143,7 @@ func (dis *Distillery) Purger() *purger.Purger {
// THESE SHOULD NEVER BE CALLED DIRECTLY
//
func (dis *Distillery) allComponents(context *lifetime.RegisterContext[component.Component, component.Still]) {
func (dis *Distillery) allComponents(context *lifetime.Registry[component.Component, component.Still]) {
lifetime.Place[*docker.Docker](context)
lifetime.Place[*binder.Binder](context)
lifetime.Place[*web.Web](context)

View file

@ -71,7 +71,11 @@ type LastRebuildFetcher struct {
}
}
func (lbr *LastRebuildFetcher) Fetch(ctx context.Context, flags ingredient.FetcherFlags, info *status.WissKI) (err error) {
info.LastRebuild, _ = lbr.dependencies.Barrel.LastRebuild(ctx)
var (
_ ingredient.WissKIFetcher = (*LastRebuildFetcher)(nil)
)
func (lbr *LastRebuildFetcher) Fetch(flags ingredient.FetcherFlags, info *status.WissKI) (err error) {
info.LastRebuild, _ = lbr.dependencies.Barrel.LastRebuild(flags.Context)
return
}

View file

@ -55,6 +55,6 @@ func (lbr *LastCronFetcher) Fetch(flags ingredient.FetcherFlags, info *status.Wi
return
}
info.LastRebuild, _ = lbr.dependencies.Drush.LastCron(flags.Context, flags.Server)
info.LastCron, _ = lbr.dependencies.Drush.LastCron(flags.Context, flags.Server)
return
}

View file

@ -143,7 +143,7 @@ func (wisski *WissKI) Theme() *extras.Theme {
// THESE SHOULD NEVER BE CALLED DIRECTLY
//
func (wisski *WissKI) allIngredients(context *lifetime.RegisterContext[ingredient.Ingredient, *liquid.Liquid]) {
func (wisski *WissKI) allIngredients(context *lifetime.Registry[ingredient.Ingredient, *liquid.Liquid]) {
// core bits
lifetime.Place[*locker.Locker](context)
lifetime.Register(context, func(m *mstore.MStore, _ *liquid.Liquid) {