Add initial support for solr
This commit is contained in:
parent
7bedeefb50
commit
b27871f39a
13 changed files with 131 additions and 31 deletions
|
|
@ -71,7 +71,7 @@ var errBootstrapCreateFile = exit.Error{
|
||||||
func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
||||||
// installation environment is the native environment!
|
// installation environment is the native environment!
|
||||||
// TODO: Should this be configurable?
|
// TODO: Should this be configurable?
|
||||||
var env environment.Native
|
env := new(environment.Native)
|
||||||
|
|
||||||
root := bs.Directory
|
root := bs.Directory
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ func (monday) Description() wisski_distillery.Description {
|
||||||
|
|
||||||
func (monday monday) AfterParse() error {
|
func (monday monday) AfterParse() error {
|
||||||
// TODO: Use a generic environment here!
|
// TODO: Use a generic environment here!
|
||||||
if !fsx.IsFile(environment.Native{}, monday.Positionals.GraphdbZip) {
|
if !fsx.IsFile(new(environment.Native), monday.Positionals.GraphdbZip) {
|
||||||
return errNoGraphDBZip.WithMessageF(monday.Positionals.GraphdbZip)
|
return errNoGraphDBZip.WithMessageF(monday.Positionals.GraphdbZip)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ var errNoGraphDBZip = exit.Error{
|
||||||
|
|
||||||
func (s systemupdate) AfterParse() error {
|
func (s systemupdate) AfterParse() error {
|
||||||
// TODO: Use a generic environment here!
|
// TODO: Use a generic environment here!
|
||||||
if !fsx.IsFile(environment.Native{}, s.Positionals.GraphdbZip) {
|
if !fsx.IsFile(new(environment.Native), s.Positionals.GraphdbZip) {
|
||||||
return errNoGraphDBZip.WithMessageF(s.Positionals.GraphdbZip)
|
return errNoGraphDBZip.WithMessageF(s.Positionals.GraphdbZip)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ type Params struct {
|
||||||
func ParamsFromEnv() (params Params, err error) {
|
func ParamsFromEnv() (params Params, err error) {
|
||||||
|
|
||||||
// try to read the base directory!
|
// try to read the base directory!
|
||||||
value, err := ReadBaseDirectory(environment.Native{}) // TODO: Are we sure about the native environment here?
|
value, err := ReadBaseDirectory(new(environment.Native)) // TODO: Are we sure about the native environment here?
|
||||||
switch {
|
switch {
|
||||||
case environment.IsNotExist(err):
|
case environment.IsNotExist(err):
|
||||||
params.ConfigPath = bootstrap.BaseDirectoryDefault
|
params.ConfigPath = bootstrap.BaseDirectoryDefault
|
||||||
|
|
|
||||||
1
internal/dis/component/solr/solr.env
Normal file
1
internal/dis/component/solr/solr.env
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
DOCKER_NETWORK_NAME=${DOCKER_NETWORK_NAME}
|
||||||
48
internal/dis/component/solr/solr.go
Normal file
48
internal/dis/component/solr/solr.go
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
package solr
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"embed"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Solr struct {
|
||||||
|
component.Base
|
||||||
|
|
||||||
|
BaseURL string // upstream solr url
|
||||||
|
|
||||||
|
PollContext context.Context // context to abort polling with
|
||||||
|
PollInterval time.Duration // duration to wait for during wait
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Solr) Path() string {
|
||||||
|
return filepath.Join(s.Still.Config.DeployRoot, "core", "solr")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Solr) Context(parent component.InstallationContext) component.InstallationContext {
|
||||||
|
return parent
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:embed all:solr
|
||||||
|
//go:embed solr.env
|
||||||
|
var resources embed.FS
|
||||||
|
|
||||||
|
func (solr *Solr) Stack(env environment.Environment) component.StackWithResources {
|
||||||
|
return component.MakeStack(solr, env, component.StackWithResources{
|
||||||
|
Resources: resources,
|
||||||
|
ContextPath: "solr",
|
||||||
|
|
||||||
|
EnvPath: "solr.env",
|
||||||
|
EnvContext: map[string]string{
|
||||||
|
"DOCKER_NETWORK_NAME": solr.Config.DockerNetworkName,
|
||||||
|
},
|
||||||
|
|
||||||
|
MakeDirs: []string{
|
||||||
|
filepath.Join("data"),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
18
internal/dis/component/solr/solr/docker-compose.yml
Normal file
18
internal/dis/component/solr/solr/docker-compose.yml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
version: "3.7"
|
||||||
|
|
||||||
|
services:
|
||||||
|
solr:
|
||||||
|
image: docker.io/library/solr:8.11-slim
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:8983:8983"
|
||||||
|
volumes:
|
||||||
|
- './data/:/var/solr'
|
||||||
|
labels:
|
||||||
|
- "eu.wiss-ki.barrel.distillery=${DOCKER_NETWORK_NAME}"
|
||||||
|
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
name: ${DOCKER_NETWORK_NAME}
|
||||||
|
external: true
|
||||||
|
|
@ -17,6 +17,7 @@ import (
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/instances/malt"
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/instances/malt"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/meta"
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/meta"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/resolver"
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/resolver"
|
||||||
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/solr"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql"
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/ssh"
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/ssh"
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/triplestore"
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/triplestore"
|
||||||
|
|
@ -50,6 +51,7 @@ type Distillery struct {
|
||||||
type Upstream struct {
|
type Upstream struct {
|
||||||
SQL string
|
SQL string
|
||||||
Triplestore string
|
Triplestore string
|
||||||
|
Solr string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Context returns a new Context belonging to this distillery
|
// Context returns a new Context belonging to this distillery
|
||||||
|
|
@ -114,6 +116,11 @@ func (dis *Distillery) allComponents() []initFunc {
|
||||||
sql.PollContext = dis.Context()
|
sql.PollContext = dis.Context()
|
||||||
sql.PollInterval = time.Second
|
sql.PollInterval = time.Second
|
||||||
}),
|
}),
|
||||||
|
manual(func(s *solr.Solr) {
|
||||||
|
s.BaseURL = dis.Upstream.Solr
|
||||||
|
s.PollContext = dis.Context()
|
||||||
|
s.PollInterval = time.Second
|
||||||
|
}),
|
||||||
|
|
||||||
// instainces
|
// instainces
|
||||||
auto[*instances.Instances],
|
auto[*instances.Instances],
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,12 @@ func NewDistillery(params cli.Params, flags cli.Flags, req cli.Requirements) (di
|
||||||
dis = &Distillery{
|
dis = &Distillery{
|
||||||
context: params.Context,
|
context: params.Context,
|
||||||
Still: component.Still{
|
Still: component.Still{
|
||||||
Environment: environment.Native{},
|
Environment: new(environment.Native),
|
||||||
},
|
},
|
||||||
Upstream: Upstream{
|
Upstream: Upstream{
|
||||||
SQL: "127.0.0.1:3306",
|
SQL: "127.0.0.1:3306",
|
||||||
Triplestore: "127.0.0.1:7200",
|
Triplestore: "127.0.0.1:7200",
|
||||||
|
Solr: "127.0.0.1:8983",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,6 +39,7 @@ func NewDistillery(params cli.Params, flags cli.Flags, req cli.Requirements) (di
|
||||||
if flags.InternalInDocker {
|
if flags.InternalInDocker {
|
||||||
dis.Upstream.SQL = "sql:3306"
|
dis.Upstream.SQL = "sql:3306"
|
||||||
dis.Upstream.Triplestore = "triplestore:7200"
|
dis.Upstream.Triplestore = "triplestore:7200"
|
||||||
|
dis.Upstream.Solr = "solr:8983"
|
||||||
params.ConfigPath = dis.Still.Environment.GetEnv("CONFIG_PATH")
|
params.ConfigPath = dis.Still.Environment.GetEnv("CONFIG_PATH")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,5 +55,5 @@ type WritableFile interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var _ Environment = Native{}
|
var _ Environment = new(Native)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
//
|
//
|
||||||
// If the command executes, it's exit code will be returned.
|
// If the command executes, it's exit code will be returned.
|
||||||
// If the command can not be executed, returns [ExecCommandError].
|
// If the command can not be executed, returns [ExecCommandError].
|
||||||
func (Native) Exec(io stream.IOStream, workdir string, exe string, argv ...string) int {
|
func (*Native) Exec(io stream.IOStream, workdir string, exe string, argv ...string) int {
|
||||||
// setup the command
|
// setup the command
|
||||||
cmd := exec.Command(exe, argv...)
|
cmd := exec.Command(exe, argv...)
|
||||||
cmd.Dir = workdir
|
cmd.Dir = workdir
|
||||||
|
|
@ -35,7 +35,7 @@ func (Native) Exec(io stream.IOStream, workdir string, exe string, argv ...strin
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n Native) LookPathAbs(file string) (string, error) {
|
func (n *Native) LookPathAbs(file string) (string, error) {
|
||||||
path, err := exec.LookPath(file)
|
path, err := exec.LookPath(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
|
||||||
|
|
@ -4,77 +4,101 @@ import (
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sync"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Native struct{}
|
type Native struct {
|
||||||
|
ulock sync.Mutex
|
||||||
|
umask int
|
||||||
|
}
|
||||||
|
|
||||||
func (Native) isEnv() {}
|
func (*Native) isEnv() {}
|
||||||
|
|
||||||
func (Native) GetEnv(name string) string {
|
func (n *Native) setMask(umask int) {
|
||||||
|
n.ulock.Lock()
|
||||||
|
n.umask = syscall.Umask(umask)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Native) resetMask() {
|
||||||
|
syscall.Umask(n.umask)
|
||||||
|
n.ulock.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Native) GetEnv(name string) string {
|
||||||
return os.Getenv(name)
|
return os.Getenv(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) Stat(path string) (fs.FileInfo, error) {
|
func (*Native) Stat(path string) (fs.FileInfo, error) {
|
||||||
return os.Stat(path)
|
return os.Stat(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) Lstat(path string) (fs.FileInfo, error) {
|
func (*Native) Lstat(path string) (fs.FileInfo, error) {
|
||||||
return os.Lstat(path)
|
return os.Lstat(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) Readlink(path string) (string, error) {
|
func (*Native) Readlink(path string) (string, error) {
|
||||||
return os.Readlink(path)
|
return os.Readlink(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) Symlink(oldname, newname string) error {
|
func (*Native) Symlink(oldname, newname string) error {
|
||||||
return os.Symlink(oldname, newname)
|
return os.Symlink(oldname, newname)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) ReadDir(name string) ([]fs.DirEntry, error) {
|
func (*Native) ReadDir(name string) ([]fs.DirEntry, error) {
|
||||||
return os.ReadDir(name)
|
return os.ReadDir(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) SameFile(f1, f2 fs.FileInfo) bool {
|
func (*Native) SameFile(f1, f2 fs.FileInfo) bool {
|
||||||
return os.SameFile(f1, f2)
|
return os.SameFile(f1, f2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) WalkDir(path string, f fs.WalkDirFunc) error {
|
func (*Native) WalkDir(path string, f fs.WalkDirFunc) error {
|
||||||
return filepath.WalkDir(path, f)
|
return filepath.WalkDir(path, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) Executable() (string, error) {
|
func (*Native) Executable() (string, error) {
|
||||||
return os.Executable() // TODO: not sure this works with the remote concepts
|
return os.Executable() // TODO: not sure this works with the remote concepts
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) Open(path string) (fs.File, error) {
|
func (*Native) Open(path string) (fs.File, error) {
|
||||||
return os.Open(path)
|
return os.Open(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) Create(path string, mode fs.FileMode) (WritableFile, error) {
|
func (n *Native) Create(path string, mode fs.FileMode) (WritableFile, error) {
|
||||||
|
n.ulock.Lock()
|
||||||
|
defer n.ulock.Unlock()
|
||||||
|
|
||||||
return os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode)
|
return os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) Chtimes(name string, atime time.Time, mtime time.Time) error {
|
func (*Native) Chtimes(name string, atime time.Time, mtime time.Time) error {
|
||||||
return os.Chtimes(name, atime, mtime)
|
return os.Chtimes(name, atime, mtime)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) Mkdir(path string, mode fs.FileMode) error {
|
func (n *Native) Mkdir(path string, mode fs.FileMode) error {
|
||||||
return os.Mkdir(path, mode)
|
n.setMask(0)
|
||||||
|
defer n.resetMask()
|
||||||
|
|
||||||
|
return os.Mkdir(path, fs.ModeDir|mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) MkdirAll(path string, mode fs.FileMode) error {
|
func (n *Native) MkdirAll(path string, mode fs.FileMode) error {
|
||||||
return os.MkdirAll(path, mode)
|
n.setMask(0)
|
||||||
|
defer n.resetMask()
|
||||||
|
|
||||||
|
return os.MkdirAll(path, fs.ModeDir|mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) Remove(path string) error {
|
func (*Native) Remove(path string) error {
|
||||||
return os.Remove(path)
|
return os.Remove(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) RemoveAll(path string) error {
|
func (*Native) RemoveAll(path string) error {
|
||||||
return os.RemoveAll(path)
|
return os.RemoveAll(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) Abs(path string) (string, error) {
|
func (*Native) Abs(path string) (string, error) {
|
||||||
return filepath.Abs(path)
|
return filepath.Abs(path)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@ import (
|
||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (Native) Listen(network, address string) (net.Listener, error) {
|
func (*Native) Listen(network, address string) (net.Listener, error) {
|
||||||
return net.Listen(network, address)
|
return net.Listen(network, address)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Native) DialContext(context context.Context, network, address string) (net.Conn, error) {
|
func (*Native) DialContext(context context.Context, network, address string) (net.Conn, error) {
|
||||||
var d net.Dialer
|
var d net.Dialer
|
||||||
return d.DialContext(context, network, address)
|
return d.DialContext(context, network, address)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue