Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

support mount code path

chen-hui-zhe-xic5c996c76e54
diff --git a/deploy/enterprise/.env.example b/deploy/enterprise/.env.example
index 8e923eef78..097c566426 100644
--- a/deploy/enterprise/.env.example
+++ b/deploy/enterprise/.env.example
@@ -17,9 +17,14 @@ RUNTIME_CODE_PATH=""
CORE_CODE_PATH=""
# 是否要给 Web 模块mount代码
-# 注意Web源代码代码需要npm run build之后,才能mount进容器,
+# 注意Web源代码代码需要npm intall之后,才能mount进容器,此操作只需要一次
IS_MOUNT_WEB_CODE="false"
+# 是否要给 Manager Web 模块mount代码
+# 注意 Manager Web 源代码代码需要npm intall之后,才能mount进容器,此操作只需要一次
+# 另外请手动创建 $RUNTIME_CODE_PATH/applications/access/user_web/dist空目录占位,满足 manager-web 对 --chat-dist 的存在性检查
+IS_MOUNT_MANAGER_WEB_CODE="false"
+
# 数据库类型,支持mysql、sqlite、postgresql, 不配默认就是sqlite
DB_TYPE="sqlite"
diff --git a/deploy/enterprise/deploy.sh b/deploy/enterprise/deploy.sh
index 0aea06fb50..ccb8765f68 100755
--- a/deploy/enterprise/deploy.sh
+++ b/deploy/enterprise/deploy.sh
@@ -65,7 +65,6 @@ process_down() {
fi
local namespace="${DEPLOY_VARS["NAMESPACE"]}"
- local client_type="${DEPLOY_VARS["AGENT_RUNTIME"]}"
# MODULES是ALL_MODULES的子集,卸载顺序倒着来
local reversed_modules=()
diff --git a/deploy/enterprise/example/gateway-env.configmap.yaml b/deploy/enterprise/example/gateway-env.configmap.yaml
index 0d20c500cc..389d184f63 100644
--- a/deploy/enterprise/example/gateway-env.configmap.yaml
+++ b/deploy/enterprise/example/gateway-env.configmap.yaml
@@ -22,7 +22,7 @@ data:
AGENT_SERVER_SESSION_CONCURRENCY: "10"
AGENT_SERVER_SESSION_TTL: "60"
API_BASE: <<API_BASE>>
- CLAW_CODE_POD_PATH: /app/jiuwenclaw
+ CLAW_POD_CODE_PATH: /app/jiuwenclaw
CLAW_MOUNT_TYPE: nfs
CLAW_NFS_PATH: <<NFS_SHARE_PATH>>/jiuwenclaw
CLAW_NFS_SERVER: <<NFS_SERVER_ADDR>>
@@ -72,7 +72,7 @@ data:
REDIS_KEY_PREFIX: 'jiuwenclaw:'
REDIS_MODE: standalone
REDIS_PORT: <<REDIS_PORT>>
- RUNTIME_CODE_POD_PATH: /usr/local/lib/python3.11/site-packages/openjiuwen_runtime
+ RUNTIME_POD_PKG_PATH: /usr/local/lib/python3.11/site-packages/openjiuwen_runtime
RUNTIME_DB_MAX_OVERFLOW: "20"
RUNTIME_DB_POOL_SIZE: "2"
RUNTIME_DB_POOL_TIMEOUT: "30"
diff --git a/deploy/enterprise/gateway_handler.sh b/deploy/enterprise/gateway_handler.sh
index aefec1164f..06b7836498 100755
--- a/deploy/enterprise/gateway_handler.sh
+++ b/deploy/enterprise/gateway_handler.sh
@@ -2,16 +2,12 @@
set -euo >/dev/null 2>&1
gen_gateway_env_file() {
- local client_type="${DEPLOY_VARS["AGENT_RUNTIME"]}"
local namespace="${DEPLOY_VARS["NAMESPACE"]}"
local env_template_file="${CONFIG["GATEWAY_ENV_TEMPLATE_FILE"]}"
- local env_name="${DEPLOY_VARS["GATEWAY_ENV_FILE_NAME"]}"
+ local envfile_name="${DEPLOY_VARS["GATEWAY_ENV_FILE_CM_NAME"]}"
local env_file="${CONFIG["GATEWAY_ENV_FILE"]}"
local deploy_mode="${DEPLOY_VARS["DEPLOYMENT_MODE"]}"
- if [ "${client_type}" != "jiuwen" ]; then
- return
- fi
if [ "${deploy_mode}" == "active-standby" ]; then
DEPLOY_VARS["GATEWAY_INSTANCE_ID"]="gateway-${namespace}"
@@ -35,13 +31,12 @@ gen_gateway_env_file() {
| awk -F'=' '$2 != ""' \
| sort > "${env_file}.tmp" && mv -f "${env_file}.tmp" "${env_file}"
- kubectl create configmap -n ${namespace} ${env_name} --from-env-file=${env_file} --dry-run=client -o yaml | yq eval 'del(.metadata.creationTimestamp)' > ${CONFIG_DIR}/gateway-env.configmap.yaml
+ kubectl create configmap -n ${namespace} ${envfile_name} --from-file=.env=${env_file} --dry-run=client -o yaml | yq eval 'del(.metadata.creationTimestamp)' > ${CONFIG_DIR}/gateway-envfile.configmap.yaml
}
gen_gateway_config_file() {
- local client_type="${DEPLOY_VARS["AGENT_RUNTIME"]}"
local field_name="feishu"
- local template_file="${TEMPLATE_DIR}/gateway-config-${client_type}.template.yaml"
+ local template_file="${TEMPLATE_DIR}/gateway-config.template.yaml"
local file="${CONFIG["GATEWAY_CONFIG_FILE"]}"
local namespace="${DEPLOY_VARS["NAMESPACE"]}"
local conf_name="${DEPLOY_VARS["GATEWAY_CONFIG_MAP_NAME"]}"
@@ -76,19 +71,13 @@ gen_gateway_config_file() {
}
gen_gateway_file() {
- local client_type="${DEPLOY_VARS["AGENT_RUNTIME"]}"
local mode="${DEPLOY_VARS["MODE"]}"
local template_file="${CONFIG["GATEWAY_TEMPLATE_FILE"]}"
local file="${CONFIG["GATEWAY_FILE"]}"
local enable_gw_lable="${DEPLOY_VARS["GATEWAY_SCHED_LABEL_ENABLED"]}"
render_config_template "${template_file}" "${file}" "DEPLOY_VARS"
- if [ "${client_type}" != "jiuwen" ]; then
- success "Gateway file generation completed: ${file}"
- return
- fi
-
- enable_dev_mode_if_needed ${file}
+ enable_dev_mode_if_needed ${file} gateway
# No need to install packages
if [[ "${mode}" == "dev" && -n "${DEPLOY_VARS["CLAW_CODE_PATH"]:-}" ]]; then
@@ -99,18 +88,6 @@ gen_gateway_file() {
add_resource_if_set "GATEWAY" "${file}"
- # Bind dedicated ServiceAccount to grant pod creation privileges
- yq eval 'select(.kind == "Deployment").spec.template.spec.serviceAccountName = "'"${DEPLOY_VARS["GATEWAY_SERVICE_ACCOUNT"]}"'"' -i "${file}"
-
- # Inject environment variables via ConfigMap binding
- yq eval '
- select(.kind == "Deployment").spec.template.spec.containers[0].envFrom += [{
- "configMapRef": {
- "name": "'"${DEPLOY_VARS["GATEWAY_ENV_FILE_NAME"]}"'"
- }
- }]
- ' -i "${file}"
-
if [[ "${mode}" != "dev" && "${enable_gw_lable}" == "true" ]]; then
# Automatically create nodeSelector and set gateway=enable
yq eval 'select(.kind == "Deployment").spec.template.spec.nodeSelector |= {"gateway": "enable"}' -i "${file}"
@@ -161,7 +138,7 @@ render_gateway_files() {
deploy_gateway() {
local namespace="${DEPLOY_VARS["NAMESPACE"]}"
- local env_name="${DEPLOY_VARS["GATEWAY_ENV_FILE_NAME"]}"
+ local envfile_name="${DEPLOY_VARS["GATEWAY_ENV_FILE_CM_NAME"]}"
local env_file="${CONFIG["GATEWAY_ENV_FILE"]}"
local conf_name="${DEPLOY_VARS["GATEWAY_CONFIG_MAP_NAME"]}"
local conf_file="${CONFIG["GATEWAY_CONFIG_FILE"]}"
@@ -172,7 +149,7 @@ deploy_gateway() {
local is_external_pvc="${DEPLOY_VARS["ENABLE_EXTERNAL_PVC"]}"
ensure_secret_configmap
- exec_cmd kubectl create configmap -n ${namespace} ${env_name} --from-env-file=${env_file}
+ exec_cmd kubectl create configmap -n ${namespace} ${envfile_name} --from-file=.env=${env_file}
exec_cmd kubectl create configmap -n ${namespace} ${conf_name} --from-file=config.yaml=${conf_file}
if [[ "${mount_type}" == "pvc" && "${is_external_pvc}" == "false" ]]; then
@@ -187,7 +164,7 @@ uninstall_gateway() {
local namespace="${DEPLOY_VARS["NAMESPACE"]}"
local gateway_name="${DEPLOY_VARS["GATEWAY_NAME"]}"
local conf_name="${DEPLOY_VARS["GATEWAY_CONFIG_MAP_NAME"]}"
- local env_name="${DEPLOY_VARS["GATEWAY_ENV_FILE_NAME"]}"
+ local envfile_name="${DEPLOY_VARS["GATEWAY_ENV_FILE_CM_NAME"]}"
local gateway_file="${CONFIG["GATEWAY_FILE"]}"
local mount_type="${DEPLOY_VARS["CLAW_MOUNT_TYPE"]}"
local pvc_file="${CONFIG["CLAW_PVC_FILE"]}"
@@ -221,7 +198,7 @@ uninstall_gateway() {
delete_k8s_resource "configmap" "${conf_name}" "${namespace}"
if [ "${DEPLOY_VARS["AGENT_RUNTIME"]}" == "jiuwen" ]; then
- delete_k8s_resource "configmap" "${env_name}" "${namespace}"
+ delete_k8s_resource "configmap" "${envfile_name}" "${namespace}"
fi
if [[ "${mount_type}" == "pvc" && -z "${DEPLOY_VARS["CLAW_PVC"]:-}" ]]; then
diff --git a/deploy/enterprise/global_vars.sh b/deploy/enterprise/global_vars.sh
index dd74d4c576..ac931c3f6f 100755
--- a/deploy/enterprise/global_vars.sh
+++ b/deploy/enterprise/global_vars.sh
@@ -69,7 +69,6 @@ declare -A CONFIG=(
["PVC_FILE"]="${CONFIG_DIR}/pvc-nfs.yaml"
)
-
# Parsed command-line arguments
declare -A ARGS=(
["CMD"]=""
@@ -82,6 +81,15 @@ declare -ga ALL_MODULES=("NFS" "NFS-SC" "RABBITMQ" "MYSQL" "REDIS" "POSTGRESQL"
declare -ga MODULES=()
declare -A DEPLOY_VARS=(
+ # for dev mode, mount code purpose
+ ["MODE"]="product"
+ ["IS_MOUNT_WEB_CODE"]="false"
+ ["IS_MOUNT_MANAGER_WEB_CODE"]="false"
+ ["CLAW_POD_CODE_PATH"]="/app/jiuwenswarm"
+ ["RUNTIME_POD_CODE_PATH"]="/app/agent-runtime"
+ ["RUNTIME_POD_PKG_PATH"]="/usr/local/lib/python3.11/site-packages/openjiuwen_runtime"
+ ["CORE_POD_PKG_PATH"]="/usr/local/lib/python3.11/site-packages/openjiuwen"
+
["AGENT_SERVER_HOME"]="/home/app"
["AGENT_SERVER_POD_NAME"]="jiuwenclaw-agentserver"
["AGENT_SERVER_SERVICE_CONCURRENCY"]="10"
@@ -89,12 +97,8 @@ declare -A DEPLOY_VARS=(
["AGENT_SERVER_SESSION_TTL"]="60"
["AGENT_BOT_ID_GROUP_NUM"]="0"
["AGENT_SERVER_REACT_MAX_ITER"]="10"
- ["CLAW_CODE_PATH"]=""
- ["CLAW_CODE_POD_PATH"]="/app/jiuwenclaw"
["CLAW_MOUNT_TYPE"]="pvc"
["CLAW_STORAGE_SIZE"]="1Gi"
- ["CORE_CODE_PATH"]=""
- ["CORE_CODE_POD_PATH"]="/usr/local/lib/python3.11/site-packages/openjiuwen"
["COLLECT_LOG_MASK_ENABLED"]="false"
["DB_TYPE"]="sqlite"
["DEPLOYMENT_MODE"]="standalone"
@@ -117,7 +121,7 @@ declare -A DEPLOY_VARS=(
["GATEWAY_DB_MAX_OVERFLOW"]="20"
["GATEWAY_DB_POOL_SIZE"]="2"
["GATEWAY_DB_POOL_TIMEOUT"]="30"
- ["GATEWAY_ENV_FILE_NAME"]="jiuwenclaw-gateway-env"
+ ["GATEWAY_ENV_FILE_CM_NAME"]="jiuwenclaw-gateway-envfile"
["GATEWAY_INSTANCE_ID"]=""
["GATEWAY_SCHED_LABEL_ENABLED"]="false"
["LOG_MASK_ENABLED"]="true"
@@ -128,7 +132,6 @@ declare -A DEPLOY_VARS=(
["GATEWAY_SERVICE_ACCOUNT"]="jiuwenclaw-gateway-sa"
["GATEWAY_SQLITE_PATH"]="gateway.db"
["IS_UP_MANAGER_WEB"]="true"
- ["IS_MOUNT_WEB_CODE"]="false"
["JIUWENBOX_CODE_POD_PATH"]="/usr/local/lib/python3.11/site-packages/jiuwenbox"
["JINA_NAME"]="jina"
["JINA_CACHE_IMAGE"]="nginx:alpine"
@@ -147,7 +150,6 @@ declare -A DEPLOY_VARS=(
["MINIO_IMAGE"]="minio/minio-arm64:RELEASE.2024-12-18T13-15-44Z"
["MINIO_NAME"]="minio"
["MINIO_STORAGE_SIZE"]="4Gi"
- ["MODE"]="product"
["MYSQL_IMAGE"]="mysql:8.0"
["MYSQL_NAME"]="mysql"
["MYSQL_ROOT_PASSWORD"]="Root@123456"
@@ -192,8 +194,6 @@ declare -A DEPLOY_VARS=(
["REDIS_PORT"]="6379"
["REDIS_MODE"]="standalone"
["RENDER_ONLY"]="false"
- ["RUNTIME_CODE_PATH"]=""
- ["RUNTIME_CODE_POD_PATH"]="/usr/local/lib/python3.11/site-packages/openjiuwen_runtime"
["SECRET_CM_NAME"]="jiuwenclaw-secret-configmap"
["TIMEZONE"]="Asia/Shanghai"
["VECTOR_NAME"]="vector-receiver"
diff --git a/deploy/enterprise/manager_handler.sh b/deploy/enterprise/manager_handler.sh
index 7d60658b95..efb469f47c 100755
--- a/deploy/enterprise/manager_handler.sh
+++ b/deploy/enterprise/manager_handler.sh
@@ -6,7 +6,7 @@ gen_manager_server_file() {
local file="${CONFIG["MANAGER_SERVER_FILE"]}"
render_config_template "${template_file}" "${file}" "DEPLOY_VARS"
- enable_dev_mode_if_needed ${file}
+ enable_dev_mode_if_needed ${file} manager-server
if [ "${DEPLOY_VARS["DB_TYPE"]}" == "postgresql" ]; then
yq eval '
@@ -33,6 +33,7 @@ render_manager_files() {
local manager_web_file="${CONFIG["MANAGER_WEB_FILE"]}"
render_config_template "${manager_web_template_file}" "${manager_web_file}" "DEPLOY_VARS"
+ enable_dev_mode_if_needed "${manager_web_file}" manager-web
add_resource_if_set "MANAGER_WEB" "${manager_web_file}"
fi
}
diff --git a/deploy/enterprise/template_handler.sh b/deploy/enterprise/template_handler.sh
index 4842ef5eb7..85d5c9d8db 100755
--- a/deploy/enterprise/template_handler.sh
+++ b/deploy/enterprise/template_handler.sh
@@ -60,137 +60,134 @@ render_config_template(){
success "Generated config file: ${destfile}"
}
-enable_dev_mode_if_needed() {
- if [ "${DEPLOY_VARS["MODE"]}" != "dev" ]; then
- return
- fi
-
- local file="$1"
- mount_claw_code_path "${file}"
- mount_runtime_code_path "${file}"
- mount_core_code_path "${file}"
-
- # Force pod to be scheduled on current master node
- yq eval 'select(.kind == "Deployment").spec.template.spec.nodeName = "'"${DEPLOY_VARS["CURRENT_NODE_NAME"]}"'"' -i "${file}"
- # Security context adaptation for root user
- yq eval 'select(.kind == "Deployment").spec.template.spec.securityContext.fsGroup = 0' -i "${file}"
- yq eval 'select(.kind == "Deployment").spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation = true' -i "${file}"
- yq eval 'select(.kind == "Deployment").spec.template.spec.containers[0].securityContext.runAsNonRoot = false' -i "${file}"
- yq eval 'select(.kind == "Deployment").spec.template.spec.containers[0].securityContext.runAsUser = 0' -i "${file}"
- yq eval 'select(.kind == "Deployment").spec.template.spec.containers[0].securityContext.runAsGroup = 0' -i "${file}"
-}
-
-
-# Mount claw source code from host into container
-mount_claw_code_path() {
- if [ -z "${DEPLOY_VARS["CLAW_CODE_PATH"]:-}" ]; then
- return
- fi
-
- local file="$1"
-
+# Append a single hostPath code mount (volume + volumeMount) to the first
+# container of every Deployment in <file>.
+add_code_mount() {
+ local file="$1" name="$2" host_path="$3" mount_path="$4"
yq eval '
- select(.kind == "Deployment").spec.template.spec.containers[0].volumeMounts += [{
- "name": "claw-code",
- "mountPath": "'"${DEPLOY_VARS["CLAW_CODE_POD_PATH"]}"'"
- }]
+ select(.kind == "Deployment").spec.template.spec.containers[0].volumeMounts
+ |= ((. // []) + [{
+ "name": "'"${name}"'",
+ "mountPath": "'"${mount_path}"'"
+ }])
' -i "${file}"
-
yq eval '
- select(.kind == "Deployment").spec.template.spec.volumes += [{
- "name": "claw-code",
- "hostPath": {
- "path": "'"${DEPLOY_VARS["CLAW_CODE_PATH"]}"'",
- "type": "Directory"
- }
- }]
+ select(.kind == "Deployment").spec.template.spec.volumes
+ |= ((. // []) + [{
+ "name": "'"${name}"'",
+ "hostPath": {
+ "path": "'"${host_path}"'",
+ "type": "Directory"
+ }
+ }])
' -i "${file}"
}
-# Mount runtime source code from host into container
-mount_runtime_code_path() {
- if [ -z "${DEPLOY_VARS["RUNTIME_CODE_PATH"]:-}" ]; then
- return
- fi
-
- local file="$1"
- local code="${DEPLOY_VARS["RUNTIME_CODE_PATH"]}"
- local mpath="${code}/management/openjiuwen_runtime/management"
- local fpath="${code}/foundation/openjiuwen_runtime/foundation"
- local pod_code="${DEPLOY_VARS["RUNTIME_CODE_POD_PATH"]}"
-
- yq eval '
- select(.kind == "Deployment").spec.template.spec.containers[0].volumeMounts += [{
- "name": "foundation-code",
- "mountPath": "'"${pod_code}/foundation"'"
- }]
- ' -i "${file}"
-
- yq eval '
- select(.kind == "Deployment").spec.template.spec.volumes += [{
- "name": "foundation-code",
- "hostPath": {
- "path": "'"${fpath}"'",
- "type": "Directory"
- }
- }]
- ' -i "${file}"
-
- yq eval '
- select(.kind == "Deployment").spec.template.spec.containers[0].volumeMounts += [{
- "name": "management-code",
- "mountPath": "'"${pod_code}/management"'"
- }]
- ' -i "${file}"
-
- yq eval '
- select(.kind == "Deployment").spec.template.spec.volumes += [{
- "name": "management-code",
- "hostPath": {
- "path": "'"${mpath}"'",
- "type": "Directory"
- }
- }]
- ' -i "${file}"
+mount_claw_code() {
+ [ -z "${DEPLOY_VARS["CLAW_CODE_PATH"]:-}" ] && return
+ add_code_mount "$1" "claw-code" \
+ "${DEPLOY_VARS["CLAW_CODE_PATH"]}" \
+ "${DEPLOY_VARS["CLAW_POD_CODE_PATH"]}"
}
-# Mount core source code from host into container
-mount_core_code_path() {
- if [ -z "${DEPLOY_VARS["CORE_CODE_PATH"]:-}" ]; then
- return
- fi
+mount_runtime_code() {
+ [ -z "${DEPLOY_VARS["RUNTIME_CODE_PATH"]:-}" ] && return
+ add_code_mount "$1" "runtime-code" \
+ "${DEPLOY_VARS["RUNTIME_CODE_PATH"]}" \
+ "${DEPLOY_VARS["RUNTIME_POD_CODE_PATH"]}"
+}
- # jjiuwenbox, manager-server and manager-web components have no dependencies on agent-core.
+mount_runtime_pkg() {
+ [ -z "${DEPLOY_VARS["RUNTIME_CODE_PATH"]:-}" ] && return
local file="$1"
- local msfile="${CONFIG["MANAGER_SERVER_FILE"]}"
- if [ "${file}" == "${msfile}" ]; then
- return
- fi
+ local src="${DEPLOY_VARS["RUNTIME_CODE_PATH"]}"
+ local dst="${DEPLOY_VARS["RUNTIME_POD_PKG_PATH"]}"
+ add_code_mount "${file}" "foundation-code" \
+ "${src}/foundation/openjiuwen_runtime/foundation" "${dst}/foundation"
+ add_code_mount "${file}" "management-code" \
+ "${src}/management/openjiuwen_runtime/management" "${dst}/management"
+}
- local code="${DEPLOY_VARS["CORE_CODE_PATH"]}/openjiuwen"
- local pod_code="${DEPLOY_VARS["CORE_CODE_POD_PATH"]}"
+mount_core_pkg() {
+ [ -z "${DEPLOY_VARS["CORE_CODE_PATH"]:-}" ] && return
+ add_code_mount "$1" "core-code" \
+ "${DEPLOY_VARS["CORE_CODE_PATH"]}/openjiuwen" \
+ "${DEPLOY_VARS["CORE_POD_PKG_PATH"]}"
+}
- yq eval '
- select(.kind == "Deployment").spec.template.spec.containers[0].volumeMounts += [{
- "name": "core-code",
- "mountPath": "'"${pod_code}"'"
- }]
- ' -i "${file}"
+# Override the container command to run the frontend vite dev server (HMR) in
+# <workdir> on <port>, bound to 0.0.0.0 so the Service/NodePort can reach it.
+# Usage: run_frontend_dev <file> <workdir> <port>
+run_frontend_dev() {
+ local file="$1" comp="$2"
+ local workdir="" port=""
+
+ case "${comp}" in
+ web)
+ [ -z "${DEPLOY_VARS["CLAW_POD_CODE_PATH"]:-}" ] && return
+ workdir="${DEPLOY_VARS["CLAW_POD_CODE_PATH"]}/jiuwenswarm/channels/web/frontend"
+ port="5173"
+ ;;
+ manager-web)
+ [ -z "${DEPLOY_VARS["RUNTIME_CODE_PATH"]:-}" ] && return
+ workdir="${DEPLOY_VARS["RUNTIME_POD_CODE_PATH"]}/applications/manager/manager_web"
+ port="5273"
+ ;;
+ *)
+ warning "run_frontend_dev: unknown component '${comp}', skipping"
+ return
+ ;;
+ esac
+
+ yq eval 'select(.kind == "Deployment").spec.template.spec.containers[0].command = ["/bin/sh", "-c"]' -i "${file}"
+ yq eval 'select(.kind == "Deployment").spec.template.spec.containers[0].args = ["cd '"${workdir}"' && npm run dev -- --host 0.0.0.0 --port '"${port}"'"]' -i "${file}"
+}
- yq eval '
- select(.kind == "Deployment").spec.template.spec.volumes += [{
- "name": "core-code",
- "hostPath": {
- "path": "'"${code}"'",
- "type": "Directory"
- }
- }]
- ' -i "${file}"
+enable_dev_mode_if_needed() {
+ [ "${DEPLOY_VARS["MODE"]}" != "dev" ] && return
+
+ local file="$1" comp="$2"
+ case "${comp}" in
+ gateway)
+ mount_claw_code "${file}"
+ mount_runtime_pkg "${file}"
+ mount_core_pkg "${file}"
+ ;;
+ web)
+ [ "${DEPLOY_VARS["IS_MOUNT_WEB_CODE"]}" != "true" ] && return
+ mount_claw_code "${file}"
+ mount_runtime_pkg "${file}"
+ mount_core_pkg "${file}"
+ run_frontend_dev "${file}" "${comp}"
+ ;;
+ manager-server)
+ mount_runtime_code "${file}"
+ ;;
+ manager-web)
+ [ "${DEPLOY_VARS["IS_MOUNT_MANAGER_WEB_CODE"]}" != "true" ] && return
+ mount_runtime_code "${file}"
+ run_frontend_dev "${file}" "${comp}"
+ ;;
+ *)
+ warning "enable_dev_mode_if_needed: unknown component '${comp}', skipping"
+ return
+ ;;
+ esac
+
+ # Pin to the current master node (hostPath is local) and run as root so
+ # the hostPath-mounted source is readable/writable inside the container.
+ yq eval 'select(.kind == "Deployment").spec.template.spec.nodeName = "'"${DEPLOY_VARS["CURRENT_NODE_NAME"]}"'"' -i "${file}"
+ yq eval 'select(.kind == "Deployment").spec.template.spec.securityContext.fsGroup = 0' -i "${file}"
+ yq eval 'select(.kind == "Deployment").spec.template.spec.containers[0].securityContext = {
+ "allowPrivilegeEscalation": true,
+ "runAsNonRoot": false,
+ "runAsUser": 0,
+ "runAsGroup": 0
+ }' -i "${file}"
}
add_resource_if_set() {
- local module=$1
- local file=$2
+ local module="$1" file="$2"
local kind_type="Deployment"
if [[ "${module}" == "MYSQL" || "${module}" == "POSTGRES" ]]; then
diff --git a/deploy/enterprise/templates/gateway.template.env b/deploy/enterprise/templates/gateway.template.env
index 7f5072bd30..f873144fad 100644
--- a/deploy/enterprise/templates/gateway.template.env
+++ b/deploy/enterprise/templates/gateway.template.env
@@ -1,6 +1,6 @@
# All values MUST NOT have quotes, no trailing spaces at line end
LOG_ROOT_PATH=/root/.logs
-EXTENSION_DIRS=<<CLAW_CODE_POD_PATH>>/packages/jiuwenclaw-ee/gateway/extensions
+EXTENSION_DIRS=<<CLAW_POD_CODE_PATH>>/packages/jiuwenclaw-ee/gateway/extensions
PIP_EXTRA_ARGS=<<PIP_EXTRA_ARGS>>
NAMESPACE=<<NAMESPACE>>
AGENT_RUNTIME=<<AGENT_RUNTIME>>
@@ -55,12 +55,12 @@ AGENT_BOT_ID_GROUP_NUM=<<AGENT_BOT_ID_GROUP_NUM>>
# K8s hostPath Configuration (for mounting host code directory)
MODE=<<MODE>>
CLAW_CODE_PATH=<<CLAW_CODE_PATH>>
-CLAW_CODE_POD_PATH=<<CLAW_CODE_POD_PATH>>
+CLAW_POD_CODE_PATH=<<CLAW_POD_CODE_PATH>>
JIUWENBOX_CODE_POD_PATH=<<JIUWENBOX_CODE_POD_PATH>>
RUNTIME_CODE_PATH=<<RUNTIME_CODE_PATH>>
-RUNTIME_CODE_POD_PATH=<<RUNTIME_CODE_POD_PATH>>
+RUNTIME_POD_PKG_PATH=<<RUNTIME_POD_PKG_PATH>>
CORE_CODE_PATH=<<CORE_CODE_PATH>>
-CORE_CODE_POD_PATH=<<CORE_CODE_POD_PATH>>
+CORE_POD_PKG_PATH=<<CORE_POD_PKG_PATH>>
NODE_NAME=<<CURRENT_NODE_NAME>>
diff --git a/deploy/enterprise/templates/gateway.template.yaml b/deploy/enterprise/templates/gateway.template.yaml
index b3d45270a9..e3f8552734 100644
--- a/deploy/enterprise/templates/gateway.template.yaml
+++ b/deploy/enterprise/templates/gateway.template.yaml
@@ -70,9 +70,9 @@ spec:
- name: gateway
image: <<GATEWAY_IMAGE>>
imagePullPolicy: IfNotPresent
- # 用于调试模式:启用后容器将保持运行,可进入 Pod 手动调试程序
- # command: ["/bin/sh"]
- # args: ["-c", "sleep infinity"]
+ # 调试模式:gateway 崩溃后容器不退出(sleep 保活),便于进 Pod 排查。
+ # command: ["/bin/sh", "-c"]
+ # args: ["jiuwenswarm-gateway; echo '[debug-keepalive] gateway exited rc=$?, sleeping'; sleep infinity"]
envFrom:
- secretRef:
name: <<SECRET_CM_NAME>>
@@ -93,9 +93,14 @@ spec:
fieldPath: metadata.namespace
volumeMounts:
- name: gateway-config
- mountPath: /root/.jiuwenclaw/config/config.yaml
+ mountPath: /root/.jiuwenswarm/config/config.yaml
subPath: config.yaml
readOnly: true
+ # 用渲染后的 gateway.env 覆盖镜像里烘焙的空 EXTENSION_DIRS .env
+ - name: gateway-env-file
+ mountPath: /root/.jiuwenswarm/config/.env
+ subPath: .env
+ readOnly: true
volumes:
- name: gateway-config
configMap:
@@ -103,3 +108,11 @@ spec:
items:
- key: config.yaml
path: config.yaml
+ # 持有渲染后 conf/gateway.env 整个文件(单 key=.env)的 configmap
+ - name: gateway-env-file
+ configMap:
+ name: <<GATEWAY_ENV_FILE_CM_NAME>>
+ items:
+ - key: .env
+ path: .env
+ serviceAccountName: <<GATEWAY_SERVICE_ACCOUNT>>
diff --git a/deploy/enterprise/update_conf.sh b/deploy/enterprise/update_conf.sh
index c1f4997160..12e078ea51 100755
--- a/deploy/enterprise/update_conf.sh
+++ b/deploy/enterprise/update_conf.sh
@@ -2,7 +2,7 @@
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
SRC_FILE=${PROJECT_DIR}/jiuwenswarm/resources/config.yaml
-DEST_FILE=${PROJECT_DIR}/deploy/enterprise/templates/gateway-config-jiuwen.template.yaml
+DEST_FILE=${PROJECT_DIR}/deploy/enterprise/templates/gateway-config.template.yaml
rm -f "${DEST_FILE}"
cp -f "${SRC_FILE}" "${DEST_FILE}"
diff --git a/deploy/enterprise/web_handler.sh b/deploy/enterprise/web_handler.sh
index 82e868fae9..8053c372c7 100755
--- a/deploy/enterprise/web_handler.sh
+++ b/deploy/enterprise/web_handler.sh
@@ -43,9 +43,7 @@ gen_web_file() {
add_resource_if_set "WEB" "${file}"
- if [ "${DEPLOY_VARS["IS_MOUNT_WEB_CODE"]}" == "true" ]; then
- enable_dev_mode_if_needed ${file}
- fi
+ enable_dev_mode_if_needed ${file} web
}
render_web_files() {
diff --git a/packages/jiuwenclaw-ee/gateway/extensions/runtime_management_extension/runtime_management_client.py b/packages/jiuwenclaw-ee/gateway/extensions/runtime_management_extension/runtime_management_client.py
index 7a1f524455..e78b188958 100644
--- a/packages/jiuwenclaw-ee/gateway/extensions/runtime_management_extension/runtime_management_client.py
+++ b/packages/jiuwenclaw-ee/gateway/extensions/runtime_management_extension/runtime_management_client.py
@@ -489,11 +489,11 @@ class RuntimeManagementAgentClient(AgentServerClient):
service_ttl = int(os.getenv("AGENT_SERVER_SERVICE_TTL", "180"))
autoscale_interval = float(os.getenv("AGENT_SERVER_AUTOSCALE_INTERVAL", "5"))
claw_code_path = os.getenv("CLAW_CODE_PATH")
- claw_code_pod_path = os.getenv("CLAW_CODE_POD_PATH")
+ claw_code_pod_path = os.getenv("CLAW_POD_CODE_PATH")
runtime_code_path = os.getenv("RUNTIME_CODE_PATH")
- runtime_code_pod_path = os.getenv("RUNTIME_CODE_POD_PATH")
+ runtime_code_pod_path = os.getenv("RUNTIME_POD_PKG_PATH")
core_code_path = os.getenv("CORE_CODE_PATH")
- core_code_pod_path = os.getenv("CORE_CODE_POD_PATH")
+ core_code_pod_path = os.getenv("CORE_POD_PKG_PATH")
configmap_name = os.getenv("AGENT_SERVER_CONFIGMAP_NAME", "")
agent_host_mounts: list[HostPathMount] = []