instances: Add methods to evaluate PHP
This commit is contained in:
parent
492a0c0404
commit
a3511b1bfc
3 changed files with 151 additions and 8 deletions
|
|
@ -1,22 +1,41 @@
|
|||
package instances
|
||||
|
||||
import "github.com/tkw1536/goprogram/stream"
|
||||
import (
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
// Info represents some info about this WissKI
|
||||
type Info struct {
|
||||
Slug string // The slug of the instance
|
||||
|
||||
Running bool // is the instance running?
|
||||
|
||||
DrupalVersion interface{} // version of drupal being used
|
||||
}
|
||||
|
||||
// Info returns info about this instance
|
||||
// Info returns information about this WissKI instance.
|
||||
func (wisski *WissKI) Info() (info Info, err error) {
|
||||
// static properties
|
||||
info.Slug = wisski.Slug
|
||||
|
||||
ps, err := wisski.Barrel().Ps(stream.FromNil())
|
||||
if err != nil {
|
||||
// dynamic properties, TODO: Add more properties here!
|
||||
var group errgroup.Group
|
||||
|
||||
group.Go(func() (err error) {
|
||||
info.Running, err = wisski.Alive()
|
||||
return
|
||||
}
|
||||
info.Running = len(ps) > 0
|
||||
})
|
||||
|
||||
err = group.Wait()
|
||||
return
|
||||
}
|
||||
|
||||
// Alive checks if this WissKI is currently running.
|
||||
func (wisski *WissKI) Alive() (bool, error) {
|
||||
ps, err := wisski.Barrel().Ps(stream.FromNil())
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return len(ps) > 0, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue