File: README.md

package info (click to toggle)
grpc-java 1.41.3%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 16,884 kB
  • sloc: java: 203,784; xml: 1,224; sh: 1,221; cpp: 1,158; makefile: 40; python: 40
file content (60 lines) | stat: -rw-r--r-- 1,766 bytes parent folder | download | duplicates (2)
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
51
52
53
54
55
56
57
58
59
60
gRPC Hostname Example
=====================

The hostname example is a Hello World server whose response includes its
hostname. It also supports health and reflection services. This makes it a good
server to test infrastructure, like load balancing.

The example requires grpc-java to already be built. You are strongly encouraged
to check out a git release tag, since there will already be a build of grpc
available. Otherwise you must follow [COMPILING](../../COMPILING.md).

### Build the example

1. Build the hello-world example client. See [the examples README](../README.md)

2. Build this server. From the `grpc-java/examples/examples-hostname` directory:
```
$ ../gradlew installDist
```

This creates the script `build/install/hostname-server/bin/hostname-server` that
runs the example.

To run the hostname example, run:

```
$ ./build/install/hostname/bin/hostname-server
```

And in a different terminal window run the hello-world client:

```
$ ../build/install/examples/bin/hello-world-client
```

### Maven

If you prefer to use Maven:
1. Build the hello-world example client. See [the examples README](../README.md)

2. Run in this directory:
```
$ mvn verify
$ # Run the server (from the examples-hostname directory)
$ mvn exec:java -Dexec.mainClass=io.grpc.examples.hostname.HostnameServer
$ # In another terminal run the client (from the examples directory)
$ cd ..
$ mvn exec:java -Dexec.mainClass=io.grpc.examples.helloworld.HelloWorldClient
```

### Bazel

If you prefer to use Bazel, run from the `grpc-java/examples` directory:
```
$ bazel build :hello-world-client example-hostname:hostname-server
$ # Run the server
$ ./bazel-bin/example-hostname/hostname-server
$ # In another terminal run the client
$ ./bazel-bin/hello-world-client
```