-
Notifications
You must be signed in to change notification settings - Fork 28
/
cloudvm_main.go
50 lines (40 loc) · 1.09 KB
/
cloudvm_main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2020 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"flag"
"fmt"
v23 "v.io/v23"
"v.io/v23/context"
"v.io/v23/rpc"
"v.io/v23/security"
"v.io/x/ref/lib/signals"
_ "v.io/x/ref/runtime/factories/static"
)
// This is as a simple server to test configuration of cloud/virtualized
// servers.
type service struct{}
func (service) Ping(ctx *context.T, call rpc.ServerCall, msg string) (string, error) {
return "ping: " + msg, nil
}
var name string
func init() {
flag.StringVar(&name, "name", "", "name of server")
}
func main() {
flag.Parse()
ctx, shutdown := v23.Init()
defer shutdown()
ctx, handler := signals.ShutdownOnSignalsWithCancel(ctx)
defer handler.WaitForSignal()
_, srv, err := v23.WithNewServer(ctx, name, service{}, security.AllowEveryone())
if err != nil {
fmt.Printf("v23.WithNewServerFailed: %v", err)
return
}
fmt.Printf("NAME=%s\n", srv.Status().Endpoints[0])
for i, ep := range srv.Status().Endpoints {
fmt.Printf("%v: %v\n", i, ep)
}
}