Skip to content

Commit

Permalink
Merge pull request #287 from owncloud/feature/pacman-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
refs authored Jun 8, 2020
2 parents 5141662 + dbd8796 commit 5a6bb24
Show file tree
Hide file tree
Showing 37 changed files with 608 additions and 322 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ fmt:
vet:
go vet $(PACKAGES)

.PHONY: staticcheck
staticcheck:
go run honnef.co/go/tools/cmd/staticcheck -tags '$(TAGS)' $(PACKAGES)

.PHONY: lint
lint:
for PKG in $(PACKAGES); do go run golang.org/x/lint/golint -set_exit_status $$PKG || exit 1; done;
Expand Down Expand Up @@ -110,6 +106,10 @@ $(BIN)/$(EXECUTABLE)-debug: $(SOURCES)
$(BIN)/$(EXECUTABLE)-linux: $(SOURCES)
GOOS=linux GOARCH=amd64 $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME)

.PHONY: staticcheck
staticcheck:
go run honnef.co/go/tools/cmd/staticcheck -tags '$(TAGS)' $(PACKAGES)

.PHONY: release
release: release-dirs release-linux release-windows release-darwin release-copy release-check

Expand Down
7 changes: 7 additions & 0 deletions changelog/unreleased/new-runtime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Change: Switch over to a new custom-built runtime

We moved away from using the go-micro runtime and are now using [our own runtime](https://github.com/refs/pman).
This allows us to spawn service processes even when they are using different versions of go-micro. On top of that we
now have the commands `ocis list`, `ocis kill` and `ocis run` available for service runtime management.

https://github.com/owncloud/ocis/pull/287
5 changes: 5 additions & 0 deletions changelog/unreleased/settings-service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Change: Make ocis-settings available

This version delivers `settings` as a new service. It is part of the array of services in the `server` command.

https://github.com/owncloud/ocis/pull/287
26 changes: 17 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,39 @@ require (
github.com/bmatcuk/doublestar v1.3.0 // indirect
github.com/chzyer/logex v1.1.10 // indirect
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect
github.com/coreos/etcd v3.3.21+incompatible // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-log/log v0.2.0 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.12.1 // indirect
github.com/karrick/godirwalk v1.15.6 // indirect
github.com/labstack/echo v3.3.10+incompatible // indirect
github.com/labstack/gommon v0.3.0 // indirect
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/micro/cli/v2 v2.1.2-0.20200203150404-894195727d9c
github.com/micro/go-micro/v2 v2.0.1-0.20200212105717-d76baf59de2e
github.com/micro/micro/v2 v2.0.1-0.20200210100719-f38a1d8d5348
github.com/micro/cli/v2 v2.1.2
github.com/micro/go-micro/v2 v2.8.0
github.com/micro/micro/v2 v2.8.0
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/nsf/termbox-go v0.0.0-20200418040025-38ba6e5628f1 // indirect
github.com/openzipkin/zipkin-go v0.2.2
github.com/owncloud/flaex v0.2.0
github.com/owncloud/ocis-accounts v0.1.1
github.com/owncloud/ocis-accounts v0.1.2-0.20200522103104-a5d5eac711c1
github.com/owncloud/ocis-glauth v0.4.0
github.com/owncloud/ocis-graph v0.0.0-20200318175820-9a5a6e029db7
github.com/owncloud/ocis-graph-explorer v0.0.0-20200210111049-017eeb40dc0c
github.com/owncloud/ocis-hello v0.1.0-alpha1.0.20200207094758-c866cafca7e5
github.com/owncloud/ocis-hello v0.1.0-alpha1.0.20200604104641-f5d5d6bafa96
github.com/owncloud/ocis-konnectd v0.3.1
github.com/owncloud/ocis-migration v0.0.0-20200504185909-72274a4f1449
github.com/owncloud/ocis-migration v0.1.1-0.20200519133726-4c6b7daff23c
github.com/owncloud/ocis-ocs v0.0.0-20200318181133-cc66a0531da7
github.com/owncloud/ocis-phoenix v0.7.0
github.com/owncloud/ocis-pkg/v2 v2.2.1
github.com/owncloud/ocis-proxy v0.3.1
github.com/owncloud/ocis-pkg/v2 v2.2.2-0.20200527082518-5641fa4a4c8c
github.com/owncloud/ocis-proxy v0.3.2-0.20200529092045-bfe4790ab8cd
github.com/owncloud/ocis-reva v0.4.0
github.com/owncloud/ocis-settings v0.0.0-20200602115916-d10179c1aa59
github.com/owncloud/ocis-thumbnails v0.1.2
github.com/owncloud/ocis-webdav v0.1.0
github.com/refs/pman v0.0.0-20200527204655-c9ccd1c53cc3
github.com/restic/calens v0.2.0
github.com/valyala/fasttemplate v1.1.0 // indirect
go.opencensus.io v0.22.3
Expand All @@ -49,3 +55,5 @@ require (
)

replace google.golang.org/grpc => google.golang.org/grpc v1.26.0

replace github.com/lucas-clemente/quic-go v0.15.7 => github.com/lucas-clemente/quic-go v0.14.1
173 changes: 133 additions & 40 deletions go.sum

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pkg/command/accounts.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/command/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Health(cfg *config.Config) *cli.Command {

defer resp.Body.Close()

if resp.StatusCode != 200 {
if resp.StatusCode != http.StatusOK {
logger.Fatal().
Int("code", resp.StatusCode).
Msg("Health seems to be in bad state")
Expand Down
55 changes: 55 additions & 0 deletions pkg/command/kill.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package command

import (
"fmt"
"log"
"net"
"net/rpc"
"os"

"github.com/micro/cli/v2"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/register"
)

// KillCommand is the entrypoint for the kill command.
func KillCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "kill",
Usage: "Kill an extension by name",
Category: "Runtime",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "hostname",
Value: "localhost",
EnvVars: []string{"OCIS_RUNTIME_HOSTNAME"},
Destination: &cfg.Runtime.Hostname,
},
&cli.StringFlag{
Name: "port",
Value: "10666",
EnvVars: []string{"OCIS_RUNTIME_PORT"},
Destination: &cfg.Runtime.Port,
},
},
Action: func(c *cli.Context) error {
client, err := rpc.DialHTTP("tcp", net.JoinHostPort(cfg.Runtime.Hostname, cfg.Runtime.Port))
if err != nil {
log.Fatal("dialing:", err)
}

var arg1 int

if err := client.Call("Service.Kill", os.Args[2], &arg1); err != nil {
log.Fatal(err)
}
fmt.Printf("process %v terminated", os.Args[2])

return nil
},
}
}

func init() {
register.AddCommand(KillCommand)
}
55 changes: 55 additions & 0 deletions pkg/command/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package command

import (
"fmt"
"log"
"net"
"net/rpc"

"github.com/micro/cli/v2"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/register"
)

// ListCommand is the entrypoint for the list command.
func ListCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "list",
Usage: "Lists running ocis extensions",
Category: "Runtime",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "hostname",
Value: "localhost",
EnvVars: []string{"OCIS_RUNTIME_HOSTNAME"},
Destination: &cfg.Runtime.Hostname,
},
&cli.StringFlag{
Name: "port",
Value: "10666",
EnvVars: []string{"OCIS_RUNTIME_PORT"},
Destination: &cfg.Runtime.Port,
},
},
Action: func(c *cli.Context) error {
client, err := rpc.DialHTTP("tcp", net.JoinHostPort(cfg.Runtime.Hostname, cfg.Runtime.Port))
if err != nil {
log.Fatal("dialing:", err)
}

var arg1 string

if err := client.Call("Service.List", struct{}{}, &arg1); err != nil {
log.Fatal(err)
}

fmt.Println(arg1)

return nil
},
}
}

func init() {
register.AddCommand(ListCommand)
}
2 changes: 2 additions & 0 deletions pkg/command/migration-import.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/proxy.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/reva-storage-public-link.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/revaauthbasic.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/revaauthbearer.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/revafrontend.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/revagateway.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/revasharing.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/revastorageeos.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/revastorageeosdata.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/revastoragehome.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/revastoragehomedata.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/revastorageoc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/revastorageocdata.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/revastorageroot.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 2 additions & 0 deletions pkg/command/revausers.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !simple

package command

import (
Expand Down
2 changes: 1 addition & 1 deletion pkg/command/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/owncloud/ocis-pkg/v2/log"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/flagset"
"github.com/owncloud/ocis/pkg/micro/runtime"
"github.com/owncloud/ocis/pkg/register"
"github.com/owncloud/ocis/pkg/runtime"
"github.com/owncloud/ocis/pkg/version"
)

Expand Down
57 changes: 57 additions & 0 deletions pkg/command/run.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package command

import (
"fmt"
"log"
"net"
"net/rpc"
"os"

"github.com/micro/cli/v2"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/register"
"github.com/refs/pman/pkg/process"
)

// RunCommand is the entrypoint for the run command.
func RunCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "run",
Usage: "Runs an extension",
Category: "Runtime",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "hostname",
Value: "localhost",
EnvVars: []string{"OCIS_RUNTIME_HOSTNAME"},
Destination: &cfg.Runtime.Hostname,
},
&cli.StringFlag{
Name: "port",
Value: "10666",
EnvVars: []string{"OCIS_RUNTIME_PORT"},
Destination: &cfg.Runtime.Port,
},
},
Action: func(c *cli.Context) error {
client, err := rpc.DialHTTP("tcp", net.JoinHostPort(cfg.Runtime.Hostname, cfg.Runtime.Port))
if err != nil {
log.Fatal("dialing:", err)
}

proc := process.NewProcEntry(os.Args[2], []string{os.Args[2]}...)
var res int

if err := client.Call("Service.Start", proc, &res); err != nil {
log.Fatal(err)
}

fmt.Println(res)
return nil
},
}
}

func init() {
register.AddCommand(RunCommand)
}
Loading

0 comments on commit 5a6bb24

Please sign in to comment.