Add support for provisioning and rebuilding via interface
This commit is contained in:
parent
f5c5999f44
commit
ddb4bb3546
76 changed files with 1306 additions and 625 deletions
|
|
@ -10,8 +10,8 @@ import (
|
|||
"github.com/FAU-CDI/wisski-distillery/internal/phpx"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/status"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/barrel"
|
||||
"github.com/tkw1536/goprogram/exit"
|
||||
"github.com/tkw1536/pkglib/stream"
|
||||
)
|
||||
|
||||
var errCronFailed = exit.Error{
|
||||
|
|
@ -20,8 +20,9 @@ var errCronFailed = exit.Error{
|
|||
}
|
||||
|
||||
func (drush *Drush) Cron(ctx context.Context, progress io.Writer) error {
|
||||
code := drush.Dependencies.Barrel.Shell(ctx, stream.NonInteractive(progress), "/runtime/cron.sh")()
|
||||
if code != 0 {
|
||||
err := drush.Exec(ctx, progress, "core-cron")
|
||||
if err != nil {
|
||||
code := err.(barrel.ExitError).Code
|
||||
// keep going, because we want to run as many crons as possible
|
||||
fmt.Fprintf(progress, "%v", errCronFailed.WithMessageF(drush.Slug, code))
|
||||
}
|
||||
|
|
@ -31,7 +32,7 @@ func (drush *Drush) Cron(ctx context.Context, progress io.Writer) error {
|
|||
|
||||
func (drush *Drush) LastCron(ctx context.Context, server *phpx.Server) (t time.Time, err error) {
|
||||
var timestamp int64
|
||||
err = drush.Dependencies.PHP.EvalCode(ctx, server, ×tamp, `$val = \Drupal::state()->get('system.cron_last'); return $val; `)
|
||||
err = drush.Dependencies.PHP.EvalCode(ctx, server, ×tamp, `return \Drupal::state()->get('system.cron_last');`)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
package drush
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/barrel"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/mstore"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php"
|
||||
"github.com/tkw1536/pkglib/stream"
|
||||
)
|
||||
|
||||
// Drush implements commands related to drush
|
||||
|
|
@ -16,3 +20,13 @@ type Drush struct {
|
|||
PHP *php.PHP
|
||||
}
|
||||
}
|
||||
|
||||
// Enable enables the given drush modules
|
||||
func (drush *Drush) Enable(ctx context.Context, progress io.Writer, modules ...string) error {
|
||||
return drush.Exec(ctx, progress, append([]string{"pm-enable", "--yes"}, modules...)...)
|
||||
}
|
||||
|
||||
func (drush *Drush) Exec(ctx context.Context, progress io.Writer, command ...string) error {
|
||||
script := append([]string{"drush"}, command...)
|
||||
return drush.Dependencies.Barrel.ShellScript(ctx, stream.NonInteractive(progress), script...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@ import (
|
|||
)
|
||||
|
||||
var errBlindUpdateFailed = exit.Error{
|
||||
Message: "failed to run blind update script for instance %q: exited with code %d",
|
||||
Message: "failed to run blind update script for instance %q",
|
||||
ExitCode: exit.ExitGeneric,
|
||||
}
|
||||
|
||||
// Update performs a blind drush update
|
||||
func (drush *Drush) Update(ctx context.Context, progress io.Writer) error {
|
||||
code := drush.Dependencies.Barrel.Shell(ctx, stream.NonInteractive(progress), "/runtime/blind_update.sh")()
|
||||
if code != 0 {
|
||||
return errBlindUpdateFailed.WithMessageF(drush.Slug, code)
|
||||
err := drush.Dependencies.Barrel.Shell(ctx, stream.NonInteractive(progress), "/runtime/blind_update.sh")
|
||||
if err != nil {
|
||||
return errBlindUpdateFailed.WithMessageF(drush.Slug).Wrap(err)
|
||||
}
|
||||
|
||||
return drush.setLastUpdate(ctx)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue