瀏覽代碼

feat(portable): export configuration for python binary

Signed-off-by: Jiyong Huang <huangjy@emqx.io>
Jiyong Huang 3 年之前
父節點
當前提交
ed069e8547

+ 26 - 0
docs/directory.json

@@ -274,6 +274,19 @@
 					"path": "plugins/functions/functions"
 					"path": "plugins/functions/functions"
 				}
 				}
 			]
 			]
+		},
+		{
+			"title": "运营",
+			"children": [
+				{
+					"title": "配置文件",
+					"path": "operation/configuration_file"
+				},
+				{
+					"title": "认证",
+					"path": "operation/authentication"
+				}
+			]
 		}
 		}
 	],
 	],
 	"en": [{
 	"en": [{
@@ -551,6 +564,19 @@
 					"path": "plugins/functions/functions"
 					"path": "plugins/functions/functions"
 				}
 				}
 			]
 			]
+		},
+		{
+			"title": "Operation",
+			"children": [
+				{
+					"title": "Configuration File",
+					"path": "operation/configuration_file"
+				},
+				{
+					"title": "Authentication",
+					"path": "operation/authentication"
+				}
+			]
 		}
 		}
 	]
 	]
 }
 }

+ 3 - 1
docs/en_US/extension/portable/python_sdk.md

@@ -4,7 +4,9 @@ By using Python SDK for portable plugins, user can develop portable plugins with
 
 
 To run python plugin, there are two prerequisites in the runtime environment:
 To run python plugin, there are two prerequisites in the runtime environment:
 1. Install Python 3.x environment.
 1. Install Python 3.x environment.
-2. Install ekuiper package by `pip install ekuiper`.
+2. Install nng and ekuiper package by `pip install nng ekuiper`.
+
+By default, the eKuiper portable plugin runtime will run python script with `python userscript.py`. If users have multiple python instance or an alternative python executable command, they can specify the python command in [the configuration file](../../operation/configuration_file.md#portable-plugin-configurations).
 
 
 ## Development
 ## Development
 
 

+ 0 - 10
docs/en_US/operation/operations.md

@@ -1,13 +1,3 @@
-## Configuration
-
-- [eKuiper basic configuration](configuration_file.md)
-- [MQTT source configuration](../rules/sources/mqtt.md)
-
-## Restful APIs
-
-eKuiper provides some RESTful management APIs. Please refer to [Rest-API doc](../restapi/overview.md) for more detailed information.
-
-
 ## Authentication
 ## Authentication
 
 
 eKuiper support ``JWT RSA256`` authentication for the RESTful management APIs since ``1.4.0`` if enabled . Users need put their Public Key in ``etc/mgmt`` folder and use the corresponding Private key to sign the JWT Tokens.
 eKuiper support ``JWT RSA256`` authentication for the RESTful management APIs since ``1.4.0`` if enabled . Users need put their Public Key in ``etc/mgmt`` folder and use the corresponding Private key to sign the JWT Tokens.

+ 12 - 1
docs/en_US/operation/configuration_file.md

@@ -66,7 +66,7 @@ The port for the rest api http server to listen to.
 The tls cert file path and key file path setting. If restTls is not set, the rest api server will listen on http. Otherwise, it will listen on https.
 The tls cert file path and key file path setting. If restTls is not set, the rest api server will listen on http. Otherwise, it will listen on https.
 
 
 ## authentication 
 ## authentication 
-eKuiper will check the ``Token`` for rest api when ``authentication`` option is true. please check this file for [more info](./operations.md).
+eKuiper will check the ``Token`` for rest api when ``authentication`` option is true. please check this file for [more info](./authentication.md).
 
 
 ```yaml
 ```yaml
 basic:
 basic:
@@ -198,4 +198,15 @@ It has properties
       sqlite:
       sqlite:
         #Sqlite file name, if left empty name of db will be sqliteKV.db
         #Sqlite file name, if left empty name of db will be sqliteKV.db
         name:
         name:
+```
+
+## Portable plugin configurations
+
+This section configures the portable plugin runtime.
+
+```yaml
+  portable:
+      # The executable of python. Specify this if you have multiple python instances in your system
+      # or other circumstance where the python executable cannot be successfully invoked through the default command.
+      pythonBin: python
 ```
 ```

+ 1 - 1
docs/en_US/operation/overview.md

@@ -2,5 +2,5 @@
 eKuiper is developed by Golang, and it can be run at different operating systems. See below docs for how to install and operating eKuiper.
 eKuiper is developed by Golang, and it can be run at different operating systems. See below docs for how to install and operating eKuiper.
 
 
 - [Install instruction](install/overview.md)
 - [Install instruction](install/overview.md)
-- [Operation guide](operations.md)
+- [Configuration File](./configuration_file.md)
 
 

+ 3 - 1
docs/zh_CN/extension/portable/python_sdk.md

@@ -4,7 +4,9 @@
 为了运行 python 插件,有两个前置条件
 为了运行 python 插件,有两个前置条件
 To run python plugin, there are two prerequisites in the runtime environment:
 To run python plugin, there are two prerequisites in the runtime environment:
 1. 安装 Python 3.x 环境.
 1. 安装 Python 3.x 环境.
-2. 通过 `pip install ekuiper` 安装 ekuiper 包.
+2. 通过 `pip install nng ekuiper` 安装 nng 和 ekuiper 包.
+
+默认情况下,eKuiper 的 portable 插件运行时会通过 `python` 命令来运行插件。如果您的环境不支持 `python` 命令,请通过[配置文件](../../operation/configuration_file.md#portable-插件配置)更换为可用的 Python 命令。
 
 
 ## 插件开发
 ## 插件开发
 
 

+ 0 - 9
docs/zh_CN/operation/operations.md

@@ -1,12 +1,3 @@
-## 配置
-
-- [eKuiper 基本配置](configuration_file.md)
-- [MQTT  源配置](../rules/sources/mqtt.md)
-
-## Restful APIs
-
-eKuiper 提供了一些 RESTful 管理 API。eKuiper 提供了一些 RESTful 管理 APIs。请参考 [Rest-API 文档](../restapi/overview.md)以获取更详细信息。
-
 ## Authentication
 ## Authentication
 
 
 如果使能的话, eKuiper 从 1.4.0 起将为 RESTful API 提供基于 ``JWT RSA256`` 的身份验证。用户需要将他们的公钥放在 ``etc/mgmt`` 文件夹中,并使用相应的私钥来签署 JWT 令牌。
 如果使能的话, eKuiper 从 1.4.0 起将为 RESTful API 提供基于 ``JWT RSA256`` 的身份验证。用户需要将他们的公钥放在 ``etc/mgmt`` 文件夹中,并使用相应的私钥来签署 JWT 令牌。

+ 12 - 1
docs/zh_CN/operation/configuration_file.md

@@ -46,7 +46,7 @@ REST http 服务器监听端口
 TLS 证书 cert 文件和 key 文件位置。如果 restTls 选项未配置,则 REST 服务器将启动为 http 服务器,否则启动为 https 服务器。
 TLS 证书 cert 文件和 key 文件位置。如果 restTls 选项未配置,则 REST 服务器将启动为 http 服务器,否则启动为 https 服务器。
 
 
 ## authentication 
 ## authentication 
-当 ``authentication`` 选项为 true 时,eKuiper 将为 rest api 请求检查 ``Token`` 。请检查此文件以获取 [更多信息](./operations.md)。
+当 ``authentication`` 选项为 true 时,eKuiper 将为 rest api 请求检查 ``Token`` 。请检查此文件以获取 [更多信息](./authentication.md)。
 
 
 ```yaml
 ```yaml
 basic:
 basic:
@@ -179,4 +179,15 @@ http://host:port/kuiper-plugins/0.9.1/alpine/functions
       sqlite:
       sqlite:
         #Sqlite file name, if left empty name of db will be sqliteKV.db
         #Sqlite file name, if left empty name of db will be sqliteKV.db
         name:
         name:
+```
+
+## Portable 插件配置
+
+配置 portable 插件的运行时属性。
+
+```yaml
+  portable:
+      # 配置 python 可执行文件的位置或命令。
+      # 若系统中有多个 python 版本,可通过此配置指定具体的 python 地址。
+      pythonBin: python
 ```
 ```

+ 1 - 1
docs/zh_CN/operation/overview.md

@@ -2,5 +2,5 @@
 eKuiper 由 Golang 开发,可以在不同的操作系统上运行。 有关如何安装和操作 eKuiper 的信息,请参见下面的文档。
 eKuiper 由 Golang 开发,可以在不同的操作系统上运行。 有关如何安装和操作 eKuiper 的信息,请参见下面的文档。
 
 
 - [安装说明](install/overview.md)
 - [安装说明](install/overview.md)
-- [操作指南](operations.md)
+- [配置文件](./configuration_file.md)
 
 

+ 7 - 1
etc/kuiper.yaml

@@ -66,4 +66,10 @@ store:
     timeout: 1000
     timeout: 1000
   sqlite:
   sqlite:
     #Sqlite file name, if left empty name of db will be sqliteKV.db
     #Sqlite file name, if left empty name of db will be sqliteKV.db
-    name:
+    name:
+
+# The settings for portable plugin
+portable:
+  # The executable of python. Specify this if you have multiple python instances in your system
+  # or other circumstance where the python executable cannot be successfully invoked through the default command.
+  pythonBin: python

+ 3 - 0
internal/conf/conf.go

@@ -72,6 +72,9 @@ type KuiperConf struct {
 			Name string `yaml:"name"`
 			Name string `yaml:"name"`
 		}
 		}
 	}
 	}
+	Portable struct {
+		PythonBin string `yaml:"pythonBin"`
+	}
 }
 }
 
 
 func InitConf() {
 func InitConf() {

+ 2 - 2
internal/plugin/portable/runtime/plugin_ins_manager.go

@@ -175,8 +175,8 @@ func (p *pluginInsManager) getOrStartProcess(pluginMeta *PluginMeta, pconf *Port
 		cmd = exec.Command(pluginMeta.Executable, string(jsonArg))
 		cmd = exec.Command(pluginMeta.Executable, string(jsonArg))
 
 
 	case "python":
 	case "python":
-		conf.Log.Printf("starting python plugin executable %s\n", pluginMeta.Executable)
-		cmd = exec.Command("python", pluginMeta.Executable, string(jsonArg))
+		conf.Log.Printf("starting python plugin executable %s with script %s\n", conf.Config.Portable.PythonBin, pluginMeta.Executable)
+		cmd = exec.Command(conf.Config.Portable.PythonBin, pluginMeta.Executable, string(jsonArg))
 	default:
 	default:
 		return nil, fmt.Errorf("unsupported language: %s", pluginMeta.Language)
 		return nil, fmt.Errorf("unsupported language: %s", pluginMeta.Language)
 	}
 	}