Skip to content

Commit

Permalink
arthas grpc service prototype (#2694)
Browse files Browse the repository at this point in the history
  • Loading branch information
x956 authored Oct 25, 2023
1 parent 8d9af06 commit 85244e9
Show file tree
Hide file tree
Showing 65 changed files with 38,787 additions and 19 deletions.
38 changes: 35 additions & 3 deletions arthas-grpc-web-proxy/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
## netty grpc web proxy
# Arthas-grpc
项目启动流程:

## 1. grpc-web代理服务配置
1. 前端grpc-web请求ip和port配置: [配置文件](./ui/src/main.js)
```js
app.use(ViewUIPlus)
.use(router)
.provide("apiHost","http://localhost:8567")
.mount('#app')
```
2. 后端端口配置: [配置文件](./src/main/java/com/taobao/arthas/grpcweb/grpc/DemoBootstrap.java), 修改``GRPC_WEB_PROXY_PORT``变量,即可配置grpc-web代理服务端口。<br><br>
若需要配置grpc服务端口和http页面服务端口, 分别修改`GRPC_PORT``HTTP_PORT`即可<br><br>
*注意, 前后端grpc-web代理服务端口需一致(默认使用端口号: 8567)
## 2. 项目编译

```shell
mvn compile
```

## 3. 项目运行

启动 [com.taobao.arthas.grpcweb.grpc.DemoBootstrap](./src/main/java/com/taobao/arthas/grpcweb/grpc/DemoBootstrap.java)

## 4. 页面访问
启动后,命令行终端会打印出访问地址
```text
Open your web browser and navigate to http://127.0.0.1:{http_port}/index.html
```

# netty grpc web proxy

本项目中使用到的grpc-web代理服务

from: https://github.com/grpc/grpc-web/tree/1.4.2/src/connector

Expand All @@ -23,13 +55,13 @@ from: https://github.com/grpc/grpc-web/tree/1.4.2/src/connector

可以用其它的 grpc web proxy来抓包辅助验证。

### 用 envoy
## 用 envoy

下载envoy 后,可以用本项目里的`envoy.yaml`

* `envoy --config-path ./envoy.yaml`

### 使用 grpcwebproxy
## 使用 grpcwebproxy

* https://github.com/improbable-eng/grpc-web/blob/master/go/grpcwebproxy/README.md

Expand Down
132 changes: 126 additions & 6 deletions arthas-grpc-web-proxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@
<artifactId>arthas-grpc-web-proxy</artifactId>
<name>arthas-grpc-web-proxy</name>
<url>https://github.com/alibaba/arthas</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<grpc.version>1.46.0</grpc.version>
<yarn.registry.url>https://registry.npmmirror.com/</yarn.registry.url>
<yarn.download.url>http://npmmirror.com</yarn.download.url>
<node.download.url>https://npmmirror.com/mirrors/node/</node.download.url>
<node.version>v16.16.0</node.version>
<yarn.version>v1.22.19</yarn.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
Expand All @@ -41,12 +49,14 @@
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-services</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
Expand All @@ -55,10 +65,19 @@
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.zeroturnaround</groupId>
<artifactId>zt-zip</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
Expand Down Expand Up @@ -89,11 +108,25 @@
<groupId>com.taobao.arthas</groupId>
<artifactId>arthas-common</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.taobao.arthas</groupId>
<artifactId>arthas-common</artifactId>
<artifactId>arthas-vmtool</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.taobao.arthas</groupId>
<artifactId>arthas-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.taobao.arthas</groupId>
<artifactId>math-game</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.taobao.arthas</groupId>
<artifactId>arthas-spy</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
Expand All @@ -111,6 +144,7 @@
</properties>
</profile>
</profiles>

<build>
<finalName>${project.artifactId}</finalName>
<extensions>
Expand All @@ -134,12 +168,98 @@
<executions>
<execution>
<goals>
<goal>test-compile</goal>
<goal>test-compile-custom</goal>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<!-- Use the latest released version:
https://repo1.maven.org/maven2/com/github/eirslett/frontend-maven-plugin/ -->
<version>1.12.1</version>
<executions>
<execution>
<!-- optional: you don't really need execution ids, but it looks nice in your build log. -->
<id>install node and yarn</id>
<goals>
<goal>install-node-and-yarn</goal>
</goals>
<!-- optional: default phase is "generate-resources" -->
<phase>generate-resources</phase>
</execution>
<execution>
<id>set registry</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>config set registry ${yarn.registry.url}</arguments>
</configuration>
</execution>
<execution>
<id>yarn install</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<!-- optional: The default argument is actually
"install", so unless you need to run some other yarn command,
you can remove this whole <configuration> section.
-->
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>run build</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
<configuration>
<nodeVersion>${node.version}</nodeVersion>
<yarnVersion>${yarn.version}</yarnVersion>

<!-- optional: where to download node from. Defaults to https://nodejs.org/dist/ -->
<nodeDownloadRoot>${node.download.url}</nodeDownloadRoot>
<!-- optional: where to download yarn from. Defaults to https://github.com/yarnpkg/yarn/releases/download/ -->
<!-- <yarnDownloadRoot>${yarn.registry.url}</yarnDownloadRoot>-->
<workingDirectory>ui</workingDirectory>

<installDirectory>target</installDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy dist</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>ui/dist</directory>
</resource>
</resources>
<outputDirectory>${project.build.directory}/static</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand Down
Loading

0 comments on commit 85244e9

Please sign in to comment.