Skip to content

Commit b448eea

Browse files
authored
Plugin: Automatically assign grpc port per default (#87)
Changes default grpc port from 50059 to 0 (auto assign). Add support for env variable GF_RENDERER_PLUGIN_GRPC_PORT to set configure grpc port.
1 parent 85ffbb8 commit b448eea

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ Due to the security risk it's not recommended to ignore HTTPS errors.
5555
GF_RENDERER_PLUGIN_IGNORE_HTTPS_ERRORS=true
5656
```
5757

58+
**gRPC port:**
59+
60+
Change the listening port of the gRPC server. Default is `0` and will automatically assign a port not in use.
61+
62+
```bash
63+
GF_RENDERER_PLUGIN_GRPC_PORT=50059
64+
```
65+
5866
## Remote Rendering Using Docker
5967

6068
Instead of installing and running the image renderer as a plugin, you can run it as a remote image rendering service using Docker. Read more about [remote rendering using Docker](https://github.com/grafana/grafana-image-renderer/blob/master/docs/remote_rendering_using_docker.md).

src/app.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ function populatePluginConfigFromEnv(config: PluginConfig, env: NodeJS.ProcessEn
7373
config.rendering.timezone = env['TZ'];
7474
}
7575

76+
if (env['GF_RENDERER_PLUGIN_GRPC_PORT']) {
77+
config.plugin.grpc.port = parseInt(env['GF_RENDERER_PLUGIN_GRPC_PORT'] as string, 10);
78+
}
79+
7680
if (env['GF_RENDERER_PLUGIN_IGNORE_HTTPS_ERRORS']) {
7781
config.rendering.ignoresHttpsErrors = env['GF_RENDERER_PLUGIN_IGNORE_HTTPS_ERRORS'] === 'true';
7882
}

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const defaultPluginConfig: PluginConfig = {
6868
plugin: {
6969
grpc: {
7070
host: '127.0.0.1',
71-
port: 50059,
71+
port: 0,
7272
},
7373
},
7474
rendering: defaultRenderingConfig,

src/plugin/grpc-plugin.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ export class GrpcPlugin {
5555
if (this.config.rendering.chromeBin) {
5656
this.log.info(
5757
'Renderer plugin started',
58+
'grpcHost',
59+
this.config.plugin.grpc.host,
60+
'grpcPort',
61+
boundPortNumber,
5862
'chromeBin',
5963
this.config.rendering.chromeBin,
6064
'ignoreHTTPSErrors',

0 commit comments

Comments
 (0)