Skip to content

Commit

Permalink
Implement updating apps
Browse files Browse the repository at this point in the history
  • Loading branch information
nkryuchkov committed Feb 27, 2020
1 parent 0d8f0a3 commit 0ddbd75
Show file tree
Hide file tree
Showing 16 changed files with 176 additions and 145 deletions.
48 changes: 48 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,54 @@ builds:
- CGO_ENABLED=0
main: ./cmd/skywire-cli/
ldflags: -s -w -X github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo.version={{.Version}} -X github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo.commit={{.ShortCommit}} -X github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo.date={{.Date}}
- id: skychat
binary: skychat
goos:
- linux
- darwin
goarch:
- amd64
- 386
- arm64
- arm
goarm:
- 7
env:
- CGO_ENABLED=0
main: ./cmd/apps/skychat/
ldflags: -s -w -X github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo.version={{.Version}} -X github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo.commit={{.ShortCommit}} -X github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo.date={{.Date}}
- id: skysocks
binary: skysocks
goos:
- linux
- darwin
goarch:
- amd64
- 386
- arm64
- arm
goarm:
- 7
env:
- CGO_ENABLED=0
main: ./cmd/apps/skysocks/
ldflags: -s -w -X github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo.version={{.Version}} -X github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo.commit={{.ShortCommit}} -X github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo.date={{.Date}}
- id: skysocks-client
binary: skysocks-client
goos:
- linux
- darwin
goarch:
- amd64
- 386
- arm64
- arm
goarm:
- 7
env:
- CGO_ENABLED=0
main: ./cmd/apps/skysocks-client/
ldflags: -s -w -X github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo.version={{.Version}} -X github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo.commit={{.ShortCommit}} -X github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo.date={{.Date}}
archives:
- format: tar.gz
wrap_in_directory: false
Expand Down
5 changes: 5 additions & 0 deletions cmd/apps/helloworld/helloworld.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ import (
"github.com/SkycoinProject/skywire-mainnet/pkg/app"
"github.com/SkycoinProject/skywire-mainnet/pkg/app/appnet"
"github.com/SkycoinProject/skywire-mainnet/pkg/routing"
"github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo"
)

const (
netType = appnet.TypeSkynet
)

func main() {
if _, err := buildinfo.Get().WriteTo(log.Writer()); err != nil {
log.Printf("Failed to output build info: %v", err)
}

clientConfig, err := app.ClientConfigFromEnv()
if err != nil {
log.Fatalf("Error getting client config: %v\n", err)
Expand Down
5 changes: 5 additions & 0 deletions cmd/apps/skychat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/SkycoinProject/skywire-mainnet/pkg/app"
"github.com/SkycoinProject/skywire-mainnet/pkg/app/appnet"
"github.com/SkycoinProject/skywire-mainnet/pkg/routing"
"github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo"
)

const (
Expand All @@ -44,6 +45,10 @@ func main() {
log = app.NewLogger(appName)
flag.Parse()

if _, err := buildinfo.Get().WriteTo(log.Writer()); err != nil {
log.Printf("Failed to output build info: %v", err)
}

clientConfig, err := app.ClientConfigFromEnv()
if err != nil {
log.Fatalf("Error getting client config: %v\n", err)
Expand Down
5 changes: 5 additions & 0 deletions cmd/apps/skysocks-client/skysocks-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/SkycoinProject/skywire-mainnet/pkg/app"
"github.com/SkycoinProject/skywire-mainnet/pkg/app/appnet"
"github.com/SkycoinProject/skywire-mainnet/pkg/routing"
"github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo"
)

const (
Expand All @@ -32,6 +33,10 @@ func main() {
log := app.NewLogger(appName)
skysocks.Log = log.PackageLogger("skysocks")

if _, err := buildinfo.Get().WriteTo(log.Writer()); err != nil {
log.Printf("Failed to output build info: %v", err)
}

var addr = flag.String("addr", skyenv.SkysocksClientAddr, "Client address to listen on")
var serverPK = flag.String("srv", "", "PubKey of the server to connect to")
flag.Parse()
Expand Down
5 changes: 5 additions & 0 deletions cmd/apps/skysocks/skysocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/SkycoinProject/skywire-mainnet/pkg/app"
"github.com/SkycoinProject/skywire-mainnet/pkg/app/appnet"
"github.com/SkycoinProject/skywire-mainnet/pkg/routing"
"github.com/SkycoinProject/skywire-mainnet/pkg/util/buildinfo"
)

const (
Expand All @@ -27,6 +28,10 @@ func main() {
log := app.NewLogger(appName)
skysocks.Log = log.PackageLogger("skysocks")

if _, err := buildinfo.Get().WriteTo(log.Writer()); err != nil {
log.Printf("Failed to output build info: %v", err)
}

var passcode = flag.String("passcode", "", "Authorize user against this passcode")

flag.Parse()
Expand Down
3 changes: 0 additions & 3 deletions cmd/skywire-cli/commands/visor/gen-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ func defaultDmsgPtyConfig() visor.DmsgPtyConfig {
func defaultSkychatConfig() visor.AppConfig {
return visor.AppConfig{
App: skyenv.SkychatName,
Version: skyenv.SkychatVersion,
AutoStart: true,
Port: routing.Port(skyenv.SkychatPort),
Args: []string{"-addr", skyenv.SkychatAddr},
Expand All @@ -178,7 +177,6 @@ func defaultSkysocksConfig(passcode string) visor.AppConfig {
}
return visor.AppConfig{
App: skyenv.SkysocksName,
Version: skyenv.SkysocksVersion,
AutoStart: true,
Port: routing.Port(skyenv.SkysocksPort),
Args: args,
Expand All @@ -188,7 +186,6 @@ func defaultSkysocksConfig(passcode string) visor.AppConfig {
func defaultSkysocksClientConfig() visor.AppConfig {
return visor.AppConfig{
App: skyenv.SkysocksClientName,
Version: skyenv.SkysocksClientVersion,
AutoStart: false,
Port: routing.Port(skyenv.SkysocksClientPort),
}
Expand Down
24 changes: 8 additions & 16 deletions internal/skyenv/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ const (
TestRouteFinderAddr = "http://routefinder.skywire.cc"
)

// Common app constants.
const (
AppProtocolVersion = "0.0.1"
)

// Default dmsg ports.
const (
DmsgSetupPort = uint16(36) // Listening port of a setup node.
Expand All @@ -36,18 +31,15 @@ const (

// Default skywire app constants.
const (
SkychatName = "skychat"
SkychatVersion = "1.0"
SkychatPort = uint16(1)
SkychatAddr = ":8000"
SkychatName = "skychat"
SkychatPort = uint16(1)
SkychatAddr = ":8000"

SkysocksName = "skysocks"
SkysocksVersion = "1.0"
SkysocksPort = uint16(3)
SkysocksName = "skysocks"
SkysocksPort = uint16(3)

SkysocksClientName = "skysocks-client"
SkysocksClientVersion = "1.0"
SkysocksClientPort = uint16(13)
SkysocksClientAddr = ":1080"
SkysocksClientName = "skysocks-client"
SkysocksClientPort = uint16(13)
SkysocksClientAddr = ":1080"
// TODO(evanlinjin): skysocks-client requires
)
1 change: 0 additions & 1 deletion pkg/app/appcommon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package appcommon
// Config defines configuration parameters for `Proc`.
type Config struct {
Name string `json:"name"`
Version string `json:"version"`
SockFilePath string `json:"sock_file_path"`
VisorPK string `json:"visor_pk"`
BinaryDir string `json:"binary_dir"`
Expand Down
7 changes: 3 additions & 4 deletions pkg/app/appserver/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Proc struct {
func NewProc(log *logging.Logger, c appcommon.Config, args []string, stdout, stderr io.Writer) (*Proc, error) {
key := appcommon.GenerateAppKey()

binaryPath := getBinaryPath(c.BinaryDir, c.Name, c.Version)
binaryPath := getBinaryPath(c.BinaryDir, c.Name)

const (
appKeyEnvFormat = appcommon.EnvAppKey + "=%s"
Expand Down Expand Up @@ -123,7 +123,6 @@ func (p *Proc) IsRunning() bool {
}

// getBinaryPath formats binary path using app dir, name and version.
func getBinaryPath(dir, name, ver string) string {
const binaryNameFormat = "%s.v%s"
return filepath.Join(dir, fmt.Sprintf(binaryNameFormat, name, ver))
func getBinaryPath(dir, name string) string {
return filepath.Join(dir, name)
}
Loading

0 comments on commit 0ddbd75

Please sign in to comment.