core: Change runtime.AppCycle to veyron2.GetAppCycle(ctx).

Change-Id: Ib306d2ad740f390c56fd32324ac618bcf3cab5df
MultiPart: 1/4
diff --git a/lib/signals/signals.go b/lib/signals/signals.go
index 7a09601..e2d64a6 100644
--- a/lib/signals/signals.go
+++ b/lib/signals/signals.go
@@ -6,6 +6,7 @@
 	"syscall"
 
 	"v.io/core/veyron2"
+	"v.io/core/veyron2/context"
 )
 
 type stopSignal string
@@ -31,7 +32,7 @@
 // none are specified, the default signals.  The first signal received will be
 // made available on the returned channel; upon receiving a second signal, the
 // process will exit.
-func ShutdownOnSignals(runtime veyron2.Runtime, signals ...os.Signal) <-chan os.Signal {
+func ShutdownOnSignals(ctx *context.T, signals ...os.Signal) <-chan os.Signal {
 	if len(signals) == 0 {
 		signals = defaultSignals()
 	}
@@ -45,9 +46,9 @@
 		case STOP:
 			if !sawStop {
 				sawStop = true
-				if runtime != nil {
+				if ctx != nil {
 					stopWaiter := make(chan string, 1)
-					runtime.AppCycle().WaitForStop(stopWaiter)
+					veyron2.GetAppCycle(ctx).WaitForStop(stopWaiter)
 					go func() {
 						for {
 							ch <- stopSignal(<-stopWaiter)
diff --git a/lib/signals/signals_test.go b/lib/signals/signals_test.go
index 387e6fe..1d7b7f4 100644
--- a/lib/signals/signals_test.go
+++ b/lib/signals/signals_test.go
@@ -12,6 +12,7 @@
 	"time"
 
 	"v.io/core/veyron2"
+	"v.io/core/veyron2/context"
 	"v.io/core/veyron2/ipc"
 	"v.io/core/veyron2/mgmt"
 	"v.io/core/veyron2/naming"
@@ -41,7 +42,7 @@
 	modules.RegisterChild("handleDefaultsIgnoreChan", "", handleDefaultsIgnoreChan)
 }
 
-func stopLoop(runtime veyron2.Runtime, stdin io.Reader, ch chan<- struct{}) {
+func stopLoop(ctx *context.T, stdin io.Reader, ch chan<- struct{}) {
 	scanner := bufio.NewScanner(stdin)
 	for scanner.Scan() {
 		switch scanner.Text() {
@@ -49,7 +50,7 @@
 			close(ch)
 			return
 		case "stop":
-			runtime.AppCycle().Stop()
+			veyron2.GetAppCycle(ctx).Stop()
 		}
 	}
 }
@@ -60,9 +61,11 @@
 		panic(err)
 	}
 
+	ctx := runtime.NewContext()
+
 	closeStopLoop := make(chan struct{})
-	go stopLoop(runtime, stdin, closeStopLoop)
-	wait := ShutdownOnSignals(runtime, signals...)
+	go stopLoop(ctx, stdin, closeStopLoop)
+	wait := ShutdownOnSignals(ctx, signals...)
 	fmt.Fprintf(stdout, "ready\n")
 	fmt.Fprintf(stdout, "received signal %s\n", <-wait)
 	runtime.Cleanup()
@@ -90,9 +93,12 @@
 		panic(err)
 	}
 	defer runtime.Cleanup()
+
+	ctx := runtime.NewContext()
+
 	closeStopLoop := make(chan struct{})
-	go stopLoop(runtime, stdin, closeStopLoop)
-	ShutdownOnSignals(runtime)
+	go stopLoop(ctx, stdin, closeStopLoop)
+	ShutdownOnSignals(ctx)
 	fmt.Fprintf(stdout, "ready\n")
 	<-closeStopLoop
 	return nil
diff --git a/runtimes/google/ipc/benchmark/bmserver/main.go b/runtimes/google/ipc/benchmark/bmserver/main.go
index 6b68072..7af2721 100644
--- a/runtimes/google/ipc/benchmark/bmserver/main.go
+++ b/runtimes/google/ipc/benchmark/bmserver/main.go
@@ -17,8 +17,10 @@
 	}
 	defer vrt.Cleanup()
 
+	ctx := vrt.NewContext()
+
 	addr, stop := benchmark.StartServer(vrt, roaming.ListenSpec)
 	vlog.Infof("Listening on %s", addr)
 	defer stop()
-	<-signals.ShutdownOnSignals(vrt)
+	<-signals.ShutdownOnSignals(ctx)
 }
diff --git a/runtimes/google/rt/mgmt_test.go b/runtimes/google/rt/mgmt_test.go
index fdd9b29..8f6fcfe 100644
--- a/runtimes/google/rt/mgmt_test.go
+++ b/runtimes/google/rt/mgmt_test.go
@@ -46,7 +46,8 @@
 // stop messages being sent on the channel passed to WaitForStop.
 func TestBasic(t *testing.T) {
 	r, _ := rt.New(profileOpt)
-	m := r.AppCycle()
+	ctx := r.NewContext()
+	m := veyron2.GetAppCycle(ctx)
 	ch := make(chan string, 1)
 	m.WaitForStop(ch)
 	for i := 0; i < 10; i++ {
@@ -66,7 +67,8 @@
 // registered wait channel.
 func TestMultipleWaiters(t *testing.T) {
 	r, _ := rt.New(profileOpt)
-	m := r.AppCycle()
+	ctx := r.NewContext()
+	m := veyron2.GetAppCycle(ctx)
 	ch1 := make(chan string, 1)
 	m.WaitForStop(ch1)
 	ch2 := make(chan string, 1)
@@ -87,7 +89,8 @@
 // Stops become no-ops.
 func TestMultipleStops(t *testing.T) {
 	r, _ := rt.New(profileOpt)
-	m := r.AppCycle()
+	ctx := r.NewContext()
+	m := veyron2.GetAppCycle(ctx)
 	ch := make(chan string, 1)
 	m.WaitForStop(ch)
 	for i := 0; i < 10; i++ {
@@ -105,7 +108,8 @@
 
 func noWaiters(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
 	r, _ := rt.New(profileOpt)
-	m := r.AppCycle()
+	ctx := r.NewContext()
+	m := veyron2.GetAppCycle(ctx)
 	fmt.Fprintf(stdout, "ready\n")
 	modules.WaitForEOF(stdin)
 	m.Stop()
@@ -134,7 +138,8 @@
 
 func forceStop(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
 	r, _ := rt.New(profileOpt)
-	m := r.AppCycle()
+	ctx := r.NewContext()
+	m := veyron2.GetAppCycle(ctx)
 	fmt.Fprintf(stdout, "ready\n")
 	modules.WaitForEOF(stdin)
 	m.WaitForStop(make(chan string, 1))
@@ -182,7 +187,8 @@
 // tracker.
 func TestProgress(t *testing.T) {
 	r, _ := rt.New(profileOpt)
-	m := r.AppCycle()
+	ctx := r.NewContext()
+	m := veyron2.GetAppCycle(ctx)
 	m.AdvanceGoal(50)
 	ch := make(chan veyron2.Task, 1)
 	m.TrackTask(ch)
@@ -213,7 +219,8 @@
 // block when the tracker channels are full.
 func TestProgressMultipleTrackers(t *testing.T) {
 	r, _ := rt.New(profileOpt)
-	m := r.AppCycle()
+	ctx := r.NewContext()
+	m := veyron2.GetAppCycle(ctx)
 	// ch1 is 1-buffered, ch2 is 2-buffered.
 	ch1, ch2 := make(chan veyron2.Task, 1), make(chan veyron2.Task, 2)
 	m.TrackTask(ch1)
@@ -250,7 +257,8 @@
 	if err != nil {
 		return err
 	}
-	m := r.AppCycle()
+	ctx := r.NewContext()
+	m := veyron2.GetAppCycle(ctx)
 	defer r.Cleanup()
 	ch := make(chan string, 1)
 	m.WaitForStop(ch)
diff --git a/runtimes/google/rt/rt.go b/runtimes/google/rt/rt.go
index 78231c9..cea3656 100644
--- a/runtimes/google/rt/rt.go
+++ b/runtimes/google/rt/rt.go
@@ -166,10 +166,6 @@
 	return rt.profile
 }
 
-func (rt *vrt) AppCycle() veyron2.AppCycle {
-	return rt.ac
-}
-
 func (rt *vrt) ConfigureReservedName(server ipc.Dispatcher, opts ...ipc.ServerOpt) {
 	rt.mu.Lock()
 	defer rt.mu.Unlock()
diff --git a/runtimes/google/rt/runtimex.go b/runtimes/google/rt/runtimex.go
index 02d0967..7062f10 100644
--- a/runtimes/google/rt/runtimex.go
+++ b/runtimes/google/rt/runtimex.go
@@ -57,6 +57,8 @@
 	ctx = context.WithValue(ctx, loggerKey, vlog.Log)
 	ctx = context.WithValue(ctx, principalKey, rt.principal)
 	ctx = context.WithValue(ctx, vtraceKey, rt.traceStore)
+	ctx = context.WithValue(ctx, profileKey, rt.profile)
+	ctx = context.WithValue(ctx, appCycleKey, rt.ac)
 	return ctx
 }
 
diff --git a/runtimes/google/rt/shutdown_servers_test.go b/runtimes/google/rt/shutdown_servers_test.go
index eca766a..5e32689 100644
--- a/runtimes/google/rt/shutdown_servers_test.go
+++ b/runtimes/google/rt/shutdown_servers_test.go
@@ -10,6 +10,7 @@
 	"syscall"
 
 	"v.io/core/veyron2"
+	"v.io/core/veyron2/context"
 	"v.io/core/veyron2/ipc"
 	"v.io/core/veyron2/rt"
 	"v.io/core/veyron2/vlog"
@@ -29,8 +30,8 @@
 func (*dummy) Echo(ipc.ServerContext) error { return nil }
 
 // makeServer sets up a simple dummy server.
-func makeServer(r veyron2.Runtime) ipc.Server {
-	server, err := r.NewServer()
+func makeServer(ctx *context.T) ipc.Server {
+	server, err := veyron2.NewServer(ctx)
 	if err != nil {
 		vlog.Fatalf("r.NewServer error: %s", err)
 	}
@@ -45,17 +46,17 @@
 
 // remoteCmdLoop listens on stdin and interprets commands sent over stdin (from
 // the parent process).
-func remoteCmdLoop(r veyron2.Runtime, stdin io.Reader) func() {
+func remoteCmdLoop(ctx *context.T, stdin io.Reader) func() {
 	done := make(chan struct{})
 	go func() {
 		scanner := bufio.NewScanner(stdin)
 		for scanner.Scan() {
 			switch scanner.Text() {
 			case "stop":
-				r.AppCycle().Stop()
+				veyron2.GetAppCycle(ctx).Stop()
 			case "forcestop":
 				fmt.Println("straight exit")
-				r.AppCycle().ForceStop()
+				veyron2.GetAppCycle(ctx).ForceStop()
 			case "close":
 				close(done)
 				return
@@ -76,19 +77,21 @@
 		vlog.Fatalf("Could not initialize runtime: %s", err)
 	}
 
+	ctx := r.NewContext()
+
 	// This is part of the test setup -- we need a way to accept
 	// commands from the parent process to simulate Stop and
 	// RemoteStop commands that would normally be issued from
 	// application code.
-	defer remoteCmdLoop(r, stdin)()
+	defer remoteCmdLoop(ctx, stdin)()
 
 	// r.Cleanup is optional, but it's a good idea to clean up, especially
 	// since it takes care of flushing the logs before exiting.
 	defer r.Cleanup()
 
 	// Create a couple servers, and start serving.
-	server1 := makeServer(r)
-	server2 := makeServer(r)
+	server1 := makeServer(ctx)
+	server2 := makeServer(ctx)
 
 	// This is how to wait for a shutdown.  In this example, a shutdown
 	// comes from a signal or a stop command.
@@ -102,7 +105,7 @@
 	// This is how to configure handling of stop commands to allow clean
 	// shutdown.
 	stopChan := make(chan string, 2)
-	r.AppCycle().WaitForStop(stopChan)
+	veyron2.GetAppCycle(ctx).WaitForStop(stopChan)
 
 	// Blocking is used to prevent the process from exiting upon receiving a
 	// second signal or stop command while critical cleanup code is
@@ -221,13 +224,6 @@
 	if err != nil {
 		vlog.Fatalf("Could not initialize runtime: %s", err)
 	}
-
-	// This is part of the test setup -- we need a way to accept
-	// commands from the parent process to simulate Stop and
-	// RemoteStop commands that would normally be issued from
-	// application code.
-	defer remoteCmdLoop(r, stdin)()
-
 	// r.Cleanup is optional, but it's a good idea to clean up, especially
 	// since it takes care of flushing the logs before exiting.
 	//
@@ -236,8 +232,16 @@
 	// allow it to execute even if a panic occurs down the road.
 	defer r.Cleanup()
 
+	ctx := r.NewContext()
+
+	// This is part of the test setup -- we need a way to accept
+	// commands from the parent process to simulate Stop and
+	// RemoteStop commands that would normally be issued from
+	// application code.
+	defer remoteCmdLoop(ctx, stdin)()
+
 	// Create a server, and start serving.
-	server := makeServer(r)
+	server := makeServer(ctx)
 
 	// This is how to wait for a shutdown.  In this example, a shutdown
 	// comes from a signal or a stop command.
@@ -245,7 +249,7 @@
 	// Note, if the developer wants to exit immediately upon receiving a
 	// signal or stop command, they can skip this, in which case the default
 	// behavior is for the process to exit.
-	waiter := signals.ShutdownOnSignals(r)
+	waiter := signals.ShutdownOnSignals(ctx)
 
 	// This communicates to the parent test driver process in our unit test
 	// that this server is ready and waiting on signals or stop commands.
diff --git a/security/agent/agentd/main.go b/security/agent/agentd/main.go
index e15ba81..69ea3d9 100644
--- a/security/agent/agentd/main.go
+++ b/security/agent/agentd/main.go
@@ -81,6 +81,8 @@
 	}
 	defer runtime.Cleanup()
 
+	ctx := runtime.NewContext()
+
 	log := runtime.Logger()
 
 	if err = os.Setenv(agent.FdVarName, "3"); err != nil {
@@ -128,7 +130,7 @@
 		shutdown := make(chan struct{})
 		go func() {
 			select {
-			case sig := <-vsignals.ShutdownOnSignals(runtime):
+			case sig := <-vsignals.ShutdownOnSignals(ctx):
 				// TODO(caprita): Should we also relay double
 				// signal to the child?  That currently just
 				// force exits the current process.
diff --git a/security/agent/pingpong/main.go b/security/agent/pingpong/main.go
index 06521f0..8bc1354 100644
--- a/security/agent/pingpong/main.go
+++ b/security/agent/pingpong/main.go
@@ -5,6 +5,7 @@
 	"fmt"
 
 	"v.io/core/veyron2"
+	"v.io/core/veyron2/context"
 	"v.io/core/veyron2/ipc"
 	"v.io/core/veyron2/rt"
 	"v.io/core/veyron2/security"
@@ -22,21 +23,21 @@
 	return "pong", nil
 }
 
-func clientMain(runtime veyron2.Runtime) {
-	log := runtime.Logger()
+func clientMain(ctx *context.T) {
+	log := veyron2.GetLogger(ctx)
 	log.Info("Pinging...")
 
 	s := PingPongClient("pingpong")
-	pong, err := s.Ping(runtime.NewContext(), "ping")
+	pong, err := s.Ping(ctx, "ping")
 	if err != nil {
 		log.Fatal("error pinging: ", err)
 	}
 	fmt.Println(pong)
 }
 
-func serverMain(r veyron2.Runtime) {
-	log := r.Logger()
-	s, err := r.NewServer()
+func serverMain(ctx *context.T) {
+	log := veyron2.GetLogger(ctx)
+	s, err := veyron2.NewServer(ctx)
 	if err != nil {
 		log.Fatal("failure creating server: ", err)
 	}
@@ -56,7 +57,7 @@
 	}
 
 	// Wait forever.
-	<-signals.ShutdownOnSignals(r)
+	<-signals.ShutdownOnSignals(ctx)
 }
 
 type allowEveryone struct{}
@@ -72,9 +73,11 @@
 	}
 	defer runtime.Cleanup()
 
+	ctx := runtime.NewContext()
+
 	if *runServer {
-		serverMain(runtime)
+		serverMain(ctx)
 	} else {
-		clientMain(runtime)
+		clientMain(ctx)
 	}
 }
diff --git a/services/identity/server/identityd.go b/services/identity/server/identityd.go
index 2ad5dcb..9ff0f72 100644
--- a/services/identity/server/identityd.go
+++ b/services/identity/server/identityd.go
@@ -72,10 +72,12 @@
 	}
 	defer runtime.Cleanup()
 
+	ctx := runtime.NewContext()
+
 	ipcServer, _, _ := s.Listen(runtime, listenSpec, host, httpaddr, tlsconfig)
 	defer ipcServer.Stop()
 
-	<-signals.ShutdownOnSignals(runtime)
+	<-signals.ShutdownOnSignals(ctx)
 }
 
 func (s *identityd) Listen(runtime veyron2.Runtime, listenSpec *ipc.ListenSpec, host, httpaddr, tlsconfig string) (ipc.Server, []string, string) {
diff --git a/services/mgmt/application/applicationd/main.go b/services/mgmt/application/applicationd/main.go
index 1a56cdc..1a4b6c6 100644
--- a/services/mgmt/application/applicationd/main.go
+++ b/services/mgmt/application/applicationd/main.go
@@ -28,6 +28,9 @@
 		vlog.Fatalf("Could not initialize runtime: %v", err)
 	}
 	defer runtime.Cleanup()
+
+	ctx := runtime.NewContext()
+
 	server, err := runtime.NewServer()
 	if err != nil {
 		vlog.Fatalf("NewServer() failed: %v", err)
@@ -53,5 +56,5 @@
 		vlog.Infof("Application repository serving at %q", epName)
 	}
 	// Wait until shutdown.
-	<-signals.ShutdownOnSignals(runtime)
+	<-signals.ShutdownOnSignals(ctx)
 }
diff --git a/services/mgmt/binary/binaryd/main.go b/services/mgmt/binary/binaryd/main.go
index 74ff1dc..7b5c4c6 100644
--- a/services/mgmt/binary/binaryd/main.go
+++ b/services/mgmt/binary/binaryd/main.go
@@ -53,6 +53,8 @@
 	}
 	defer runtime.Cleanup()
 
+	ctx := runtime.NewContext()
+
 	rootDir, err := impl.SetupRootDir(*rootDirFlag)
 	if err != nil {
 		vlog.Errorf("SetupRootDir(%q) failed: %v", *rootDirFlag, err)
@@ -101,5 +103,5 @@
 		vlog.Infof("Binary repository serving at %q", epName)
 	}
 	// Wait until shutdown.
-	<-signals.ShutdownOnSignals(runtime)
+	<-signals.ShutdownOnSignals(ctx)
 }
diff --git a/services/mgmt/build/buildd/main.go b/services/mgmt/build/buildd/main.go
index 09823c4..da50f8b 100644
--- a/services/mgmt/build/buildd/main.go
+++ b/services/mgmt/build/buildd/main.go
@@ -27,6 +27,9 @@
 		vlog.Fatalf("Could not initialize runtime: %v", err)
 	}
 	defer runtime.Cleanup()
+
+	ctx := runtime.NewContext()
+
 	server, err := runtime.NewServer()
 	if err != nil {
 		vlog.Errorf("NewServer() failed: %v", err)
@@ -45,5 +48,5 @@
 	vlog.Infof("Build server running at endpoint=%q", endpoint)
 
 	// Wait until shutdown.
-	<-signals.ShutdownOnSignals(runtime)
+	<-signals.ShutdownOnSignals(ctx)
 }
diff --git a/services/mgmt/device/deviced/server.go b/services/mgmt/device/deviced/server.go
index efc649a..5ab0693 100644
--- a/services/mgmt/device/deviced/server.go
+++ b/services/mgmt/device/deviced/server.go
@@ -29,6 +29,8 @@
 	}
 	defer runtime.Cleanup()
 
+	ctx := runtime.NewContext()
+
 	server, err := runtime.NewServer()
 	if err != nil {
 		vlog.Errorf("NewServer() failed: %v", err)
@@ -66,7 +68,7 @@
 	impl.InvokeCallback(runtime.NewContext(), name)
 
 	// Wait until shutdown.
-	<-signals.ShutdownOnSignals(runtime)
+	<-signals.ShutdownOnSignals(ctx)
 
 	return exitErr
 }
diff --git a/services/mgmt/device/impl/device_service.go b/services/mgmt/device/impl/device_service.go
index 8c9f611..02ad0b2 100644
--- a/services/mgmt/device/impl/device_service.go
+++ b/services/mgmt/device/impl/device_service.go
@@ -196,8 +196,7 @@
 	if err := updateLink(s.config.Previous, s.config.CurrentLink); err != nil {
 		return err
 	}
-	runtime := veyron2.RuntimeFromContext(ctx)
-	runtime.AppCycle().Stop()
+	veyron2.GetAppCycle(ctx).Stop()
 	return nil
 }
 
@@ -402,8 +401,7 @@
 		return err
 	}
 
-	runtime := veyron2.RuntimeFromContext(ctx)
-	runtime.AppCycle().Stop()
+	veyron2.GetAppCycle(ctx).Stop()
 	deferrer = nil
 	return nil
 }
@@ -446,17 +444,15 @@
 }
 
 func (s *deviceService) Stop(call ipc.ServerContext, _ uint32) error {
-	runtime := veyron2.RuntimeFromContext(call.Context())
 	if s.stopHandler != nil {
 		s.stopHandler()
 	}
-	runtime.AppCycle().Stop()
+	veyron2.GetAppCycle(call.Context()).Stop()
 	return nil
 }
 
 func (*deviceService) Suspend(call ipc.ServerContext) error {
-	runtime := veyron2.RuntimeFromContext(call.Context())
-	runtime.AppCycle().Stop()
+	veyron2.GetAppCycle(call.Context()).Stop()
 	return nil
 }
 
diff --git a/services/mgmt/device/impl/impl_test.go b/services/mgmt/device/impl/impl_test.go
index f9e619d..d521e5f 100644
--- a/services/mgmt/device/impl/impl_test.go
+++ b/services/mgmt/device/impl/impl_test.go
@@ -86,16 +86,20 @@
 
 var globalRT veyron2.Runtime
 
+var globalCtx *context.T
+
 func initRT(opts ...veyron2.ROpt) {
 	var err error
 	if globalRT, err = rt.New(opts...); err != nil {
 		panic(err)
 	}
 
+	globalCtx = globalRT.NewContext()
+
 	// Disable the cache because we will be manipulating/using the namespace
 	// across multiple processes and want predictable behaviour without
 	// relying on timeouts.
-	globalRT.Namespace().CacheCtl(naming.DisableCache(true))
+	veyron2.GetNamespace(globalCtx).CacheCtl(naming.DisableCache(true))
 }
 
 // TestHelperProcess is the entrypoint for the modules commands in a
@@ -187,7 +191,7 @@
 
 	fmt.Fprintf(stdout, "ready:%d\n", os.Getpid())
 
-	<-signals.ShutdownOnSignals(globalRT)
+	<-signals.ShutdownOnSignals(globalCtx)
 
 	if val, present := env["PAUSE_BEFORE_STOP"]; present && val == "1" {
 		modules.WaitForEOF(stdin)
@@ -258,7 +262,7 @@
 	vlog.FlushLog()
 	ping()
 
-	<-signals.ShutdownOnSignals(globalRT)
+	<-signals.ShutdownOnSignals(globalCtx)
 	if err := ioutil.WriteFile("testfile", []byte("goodbye world"), 0600); err != nil {
 		vlog.Fatalf("Failed to write testfile: %v", err)
 	}
diff --git a/services/mgmt/profile/profiled/main.go b/services/mgmt/profile/profiled/main.go
index 10f5428..e11d1cb 100644
--- a/services/mgmt/profile/profiled/main.go
+++ b/services/mgmt/profile/profiled/main.go
@@ -3,6 +3,7 @@
 import (
 	"flag"
 
+	"v.io/core/veyron2"
 	"v.io/core/veyron2/rt"
 	"v.io/core/veyron2/vlog"
 
@@ -27,7 +28,10 @@
 		vlog.Fatalf("Could not initialize runtime: %v", err)
 	}
 	defer runtime.Cleanup()
-	server, err := runtime.NewServer()
+
+	ctx := runtime.NewContext()
+
+	server, err := veyron2.NewServer(ctx)
 	if err != nil {
 		vlog.Fatalf("NewServer() failed: %v", err)
 	}
@@ -48,5 +52,5 @@
 	vlog.Infof("Profile repository running at endpoint=%q", endpoint)
 
 	// Wait until shutdown.
-	<-signals.ShutdownOnSignals(runtime)
+	<-signals.ShutdownOnSignals(ctx)
 }
diff --git a/services/mounttable/mounttabled/mounttable.go b/services/mounttable/mounttabled/mounttable.go
index 6af16c2..5c3fe2c 100644
--- a/services/mounttable/mounttabled/mounttable.go
+++ b/services/mounttable/mounttabled/mounttable.go
@@ -6,6 +6,7 @@
 	"net"
 	"os"
 
+	"v.io/core/veyron2"
 	"v.io/core/veyron2/naming"
 	"v.io/core/veyron2/options"
 	"v.io/core/veyron2/rt"
@@ -29,7 +30,9 @@
 	}
 	defer r.Cleanup()
 
-	mtServer, err := r.NewServer(options.ServesMountTable(true))
+	ctx := r.NewContext()
+
+	mtServer, err := veyron2.NewServer(ctx, options.ServesMountTable(true))
 	if err != nil {
 		vlog.Errorf("r.NewServer failed: %v", err)
 		os.Exit(1)
@@ -88,5 +91,5 @@
 	}
 
 	// Wait until signal is received.
-	vlog.Info("Received signal ", <-signals.ShutdownOnSignals(r))
+	vlog.Info("Received signal ", <-signals.ShutdownOnSignals(ctx))
 }
diff --git a/tools/debug/impl.go b/tools/debug/impl.go
index 7bdc1d3..e895973 100644
--- a/tools/debug/impl.go
+++ b/tools/debug/impl.go
@@ -526,7 +526,9 @@
 	fmt.Fprintln(cmd.Stdout())
 	fmt.Fprintln(cmd.Stdout(), "Hit CTRL-C to exit")
 
-	<-signals.ShutdownOnSignals(runtime)
+	ctx := runtime.NewContext()
+
+	<-signals.ShutdownOnSignals(ctx)
 	return nil
 }