system_update: Perform provisioning in parallel
This commit is contained in:
parent
c091761762
commit
72d95f58ea
15 changed files with 182 additions and 27 deletions
|
|
@ -31,7 +31,7 @@ func (control Control) Path() string {
|
|||
var resources embed.FS
|
||||
|
||||
func (control *Control) Stack(env environment.Environment) component.StackWithResources {
|
||||
return component.MakeStack(control, env, component.StackWithResources{
|
||||
stt := component.MakeStack(control, env, component.StackWithResources{
|
||||
Resources: resources,
|
||||
ContextPath: "control",
|
||||
EnvPath: "control.env",
|
||||
|
|
@ -52,6 +52,7 @@ func (control *Control) Stack(env environment.Environment) component.StackWithRe
|
|||
TouchFiles: []string{control.ResolverFile},
|
||||
CopyContextFiles: []string{core.Executable},
|
||||
})
|
||||
return stt
|
||||
}
|
||||
|
||||
func (control Control) Context(parent component.InstallationContext) component.InstallationContext {
|
||||
|
|
|
|||
29
internal/component/instances/php/settings.php
Normal file
29
internal/component/instances/php/settings.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/** gets a setting from 'settings.php' */
|
||||
function get_setting($name) {
|
||||
use \Drupal\Core\Site\Settings;
|
||||
return Settings::get($name);
|
||||
}
|
||||
|
||||
/** sets a setting in 'settings.php' */
|
||||
function set_setting($name, $value) {
|
||||
// load install.inc
|
||||
if(is_file(DRUPAL_ROOT . "/internal/")) {
|
||||
include_once DRUPAL_ROOT . "/internal/core/includes/install.inc";
|
||||
} else {
|
||||
include_once DRUPAL_ROOT . "/core/includes/install.inc";
|
||||
}
|
||||
|
||||
// update the provided setting
|
||||
$settings["settings"][$name] = (object)[
|
||||
"value" => $value,
|
||||
"required" => TRUE,
|
||||
];
|
||||
|
||||
// find the filename
|
||||
$filename = DRUPAL_ROOT . "/" . \Drupal::service("site.path") . "/settings.php";
|
||||
drupal_rewrite_settings($settings, $filename);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ var exportPathbuilderPHP string
|
|||
|
||||
// Pathbuilders returns the ids of all pathbuilders in consistent order.
|
||||
func (wisski *WissKI) Pathbuilders() (ids []string, err error) {
|
||||
err = wisski.ExecPHPScript(stream.FromNil(), &ids, exportPathbuilderPHP, "all_list")
|
||||
err = wisski.ExecPHPScript(stream.FromDebug(), &ids, exportPathbuilderPHP, "all_list")
|
||||
slices.Sort(ids)
|
||||
return
|
||||
}
|
||||
|
|
@ -25,13 +25,13 @@ func (wisski *WissKI) Pathbuilders() (ids []string, err error) {
|
|||
// Pathbuilder returns a single pathbuilder as xml.
|
||||
// If it does not exist, it returns the empty string and nil error.
|
||||
func (wisski *WissKI) Pathbuilder(id string) (xml string, err error) {
|
||||
err = wisski.ExecPHPScript(stream.FromNil(), &xml, exportPathbuilderPHP, "one_xml", id)
|
||||
err = wisski.ExecPHPScript(stream.FromDebug(), &xml, exportPathbuilderPHP, "one_xml", id)
|
||||
return
|
||||
}
|
||||
|
||||
// AllPathbuilders returns all pathbuilders serialized as xml
|
||||
func (wisski *WissKI) AllPathbuilders() (pathbuilders map[string]string, err error) {
|
||||
err = wisski.ExecPHPScript(stream.FromNil(), &pathbuilders, exportPathbuilderPHP, "all_xml")
|
||||
err = wisski.ExecPHPScript(stream.FromDebug(), &pathbuilders, exportPathbuilderPHP, "all_xml")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
var ErrExecInvalidCode = errors.New("invalid code to execute")
|
||||
|
|
@ -123,3 +125,17 @@ func marshalPHP(data any) (string, error) {
|
|||
result := "call_user_func(function(){$x=<<<'" + delim + "'\n" + jstring + "\n" + delim + ";return json_decode(trim($x));})" // press to doubt
|
||||
return result, nil
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
//go:embed php/settings.php
|
||||
var settingsPHP string
|
||||
|
||||
func (wisski *WissKI) GetSettingsPHP(key string) (value any, err error) {
|
||||
err = wisski.ExecPHPScript(stream.FromDebug(), &value, settingsPHP, "get_setting", key)
|
||||
return
|
||||
}
|
||||
|
||||
func (wisski *WissKI) SetSettingsPHP(key string, value any) error {
|
||||
return wisski.ExecPHPScript(stream.FromDebug(), nil, settingsPHP, "set_setting", key, value)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ var listURIPrefixesPHP string
|
|||
// Prefixes returns the prefixes
|
||||
func (wisski *WissKI) Prefixes() (prefixes []string, err error) {
|
||||
// get all the ugly prefixes
|
||||
err = wisski.ExecPHPScript(stream.FromNil(), &prefixes, listURIPrefixesPHP, "list_prefixes")
|
||||
err = wisski.ExecPHPScript(stream.FromDebug(), &prefixes, listURIPrefixesPHP, "list_prefixes")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"sync/atomic"
|
||||
|
||||
mysqldriver "github.com/go-sql-driver/mysql"
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
|
|
@ -43,7 +44,6 @@ func (sql *SQL) Exec(query string, args ...interface{}) error {
|
|||
func (sql *SQL) WaitExec() error {
|
||||
return wait.Wait(func() bool {
|
||||
err := sql.Exec("select 1;")
|
||||
// log.Printf("[WaitQuery] %s\n", err) // debug
|
||||
return err == nil
|
||||
}, sql.PollInterval, sql.PollContext)
|
||||
}
|
||||
|
|
@ -90,8 +90,10 @@ func (sql *SQL) QueryTable(silent bool, table string) (*gorm.DB, error) {
|
|||
|
||||
// WaitQueryTable waits for a connection to succeed via QueryTable
|
||||
func (sql *SQL) WaitQueryTable() error {
|
||||
n := stream.FromDebug()
|
||||
return wait.Wait(func() bool {
|
||||
_, err := sql.QueryTable(true, models.InstanceTable)
|
||||
n.EPrintf("[SQL.WaitQueryTable]: %s\n", err)
|
||||
return err == nil
|
||||
}, sql.PollInterval, sql.PollContext)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ func (sql *SQL) Shell(io stream.IOStream, argv ...string) (int, error) {
|
|||
|
||||
// unsafeWaitShell waits for a connection via the database shell to succeed
|
||||
func (sql *SQL) unsafeWaitShell() error {
|
||||
n := stream.FromNil()
|
||||
n := stream.FromDebug()
|
||||
return wait.Wait(func() bool {
|
||||
code, err := sql.Shell(n, "-e", "select 1;")
|
||||
// log.Printf("[unsafeWaitShell] %d %s\n", code, err) // debug
|
||||
n.EPrintf("[SQL.unsafeWaitShell]: %d %s\n", code, err)
|
||||
return err == nil && code == 0
|
||||
}, sql.PollInterval, sql.PollContext)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ func (ds Stack) Exec(io stream.IOStream, service, executable string, args ...str
|
|||
return ds.compose(io, compose...)
|
||||
}
|
||||
|
||||
// Run executes the provided service with the given executable.
|
||||
// Run runs a command in a running container with the given executable.
|
||||
// It is equivalent to 'docker compose run [--rm] $service $executable $args...'.
|
||||
//
|
||||
// It returns the exit code of the process.
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/wait"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
)
|
||||
|
||||
type TriplestoreUserPayload struct {
|
||||
|
|
@ -85,8 +86,10 @@ func (ts Triplestore) OpenRaw(method, url string, body interface{}, bodyName str
|
|||
// Wait waits for the connection to the Triplestore to succeed.
|
||||
// This is achieved using a polling strategy.
|
||||
func (ts Triplestore) Wait() error {
|
||||
n := stream.FromDebug()
|
||||
return wait.Wait(func() bool {
|
||||
res, err := ts.OpenRaw("GET", "/rest/repositories", nil, "", "")
|
||||
n.EPrintf("[Triplestore.Wait]: %s\n", err)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package web
|
|||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/component"
|
||||
|
|
@ -22,7 +21,6 @@ func (Web) Name() string {
|
|||
|
||||
func (web Web) Path() string {
|
||||
res := filepath.Join(web.Core.Config.DeployRoot, "core", web.Name())
|
||||
fmt.Println("debug====" + res)
|
||||
return res
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue