当前位置: 首页 > news >正文

OpenClaw人人养虾:后台执行

生产环境中,Gateway 通常需要以守护进程(Daemon)模式在后台运行,并在系统启动时自动启动、崩溃后自动重启。

内置 Daemon 模式

# 以守护进程模式启动 openclaw gateway --daemon # 查看状态 openclaw status # 停止 openclaw gateway stop

开发 vs 生产

开发时使用前台模式(直接openclaw gateway)方便查看日志。生产环境使用下述进程管理器确保可靠运行。

systemd(Linux 推荐)

创建服务文件

# /etc/systemd/system/openclaw.service [Unit] Description=OpenClaw Gateway Documentation=https://docs.openclaw.dev After=network-online.target Wants=network-online.target [Service] Type=simple User=openclaw Group=openclaw WorkingDirectory=/home/openclaw Environment=OPENCLAW_GATEWAY_TOKEN=your-token-here Environment=OPENCLAW_GATEWAY_HOST=0.0.0.0 ExecStart=/usr/local/bin/openclaw gateway Restart=always RestartSec=5 StandardOutput=journal StandardError=journal # 安全加固 NoNewPrivileges=true ProtectSystem=strict ProtectHome=read-only ReadWritePaths=/home/openclaw/.openclaw [Install] WantedBy=multi-user.target

管理服务

# 重新加载服务配置 sudo systemctl daemon-reload # 启用开机自启 sudo systemctl enable openclaw # 启动 sudo systemctl start openclaw # 查看状态 sudo systemctl status openclaw # 查看日志 sudo journalctl -u openclaw -f # 停止 sudo systemctl stop openclaw # 重启 sudo systemctl restart openclaw

systemd 安全

服务文件中的NoNewPrivilegesProtectSystemProtectHome提供额外的系统级安全隔离。

launchd(macOS 推荐)

创建 plist 文件

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>dev.openclaw.gateway</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/openclaw</string> <string>gateway</string> </array> <key>EnvironmentVariables</key> <dict> <key>OPENCLAW_GATEWAY_TOKEN</key> <string>your-token-here</string> </dict> <key>RunAtLoad</key> <true/> <key>KeepAlive</key> <true/> <key>StandardOutPath</key> <string>/tmp/openclaw.stdout.log</string> <key>StandardErrorPath</key> <string>/tmp/openclaw.stderr.log</string> </dict> </plist>

管理服务

# 安装 plist cp dev.openclaw.gateway.plist ~/Library/LaunchAgents/ # 加载并启动 launchctl load ~/Library/LaunchAgents/dev.openclaw.gateway.plist # 查看状态 launchctl list | grep openclaw # 停止并卸载 launchctl unload ~/Library/LaunchAgents/dev.openclaw.gateway.plist

pm2(跨平台 Node.js 进程管理器)

安装 pm2

npm install -g pm2

配置和启动

# 直接启动 pm2 start openclaw -- gateway # 或使用配置文件 pm2 start ecosystem.config.js
// ecosystem.config.js module.exports = { apps: [{ name: 'openclaw-gateway', script: 'openclaw', args: 'gateway', env: { OPENCLAW_GATEWAY_TOKEN: 'your-token-here', OPENCLAW_GATEWAY_HOST: '0.0.0.0' }, restart_delay: 5000, max_restarts: 10, autorestart: true }] };

管理

# 查看状态 pm2 status # 查看日志 pm2 logs openclaw-gateway # 停止 pm2 stop openclaw-gateway # 重启 pm2 restart openclaw-gateway # 设置开机自启 pm2 startup pm2 save

Docker 容器

使用 Docker

docker run -d \ --name openclaw-gateway \ -p 18789:18789 \ -e OPENCLAW_GATEWAY_TOKEN=your-token \ -e OPENCLAW_GATEWAY_HOST=0.0.0.0 \ -v openclaw-data:/root/.openclaw \ --restart unless-stopped \ openclaw/gateway:latest

使用 Docker Compose

# docker-compose.yml version: "3.8" services: openclaw: image: openclaw/gateway:latest container_name: openclaw-gateway ports: - "18789:18789" environment: - OPENCLAW_GATEWAY_TOKEN=${GATEWAY_TOKEN} - OPENCLAW_GATEWAY_HOST=0.0.0.0 volumes: - openclaw-data:/root/.openclaw restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:18789/health"] interval: 30s timeout: 10s retries: 3 volumes: openclaw-data:
# 启动 docker compose up -d # 查看日志 docker compose logs -f openclaw # 停止 docker compose down

方案对比

方案平台自动重启开机自启日志管理
systemdLinuxjournald
launchdmacOS文件
pm2跨平台内置
Docker跨平台docker logs
内置 daemon跨平台文件

选择建议

  • Linux 服务器→ systemd
  • macOS→ launchd
  • 跨平台/简单→ pm2
  • 容器化部署→ Docker

《DeepSeek高效数据分析:从数据清洗到行业案例》聚焦DeepSeek在数据分析领域的高效应用,是系统讲解其从数据处理到可视化全流程的实用指南。作者结合多年职场实战经验,不仅深入拆解DeepSeek数据分析的核心功能——涵盖数据采集、清洗、预处理、探索分析、建模(回归、聚类、时间序列等)及模型评估,更通过金融量化数据分析、电商平台数据分析等真实行业案例,搭配报告撰写技巧,提供独到见解与落地建议。助力职场人在激烈竞争中凭借先进技能突破瓶颈,实现职业进阶,开启发展新篇。

http://www.jsqmd.com/news/587727/

相关文章:

  • MySQL函数及条件查询相关用法
  • 2025_NIPS_Fast Monte Carlo Tree Diffusion: 100× Speedup via Parallel Sparse Planning
  • AI赋能论文研究:调用快马平台模型智能分析文本与提取关键词
  • OpenClaw多终端控制:千问3.5-9B实现跨设备协同
  • DREAM3D:革新材料科学数据处理的开源框架
  • Git 仓库搬家后,如何让本地仓库“认新家”?——小白也能看懂的远程地址修改指南
  • 效率提升:用快马AI快速生成带存储功能的EndNote工具
  • GHelper:华硕笔记本的终极开源性能控制解决方案
  • Redis怎样动态添加新的哨兵节点_直接启动新Sentinel并让其通过主库自动发现其他哨兵
  • 代码随想录—day2—滑动窗口与前缀和
  • ABAP 选择屏幕中创建多个自定义按钮
  • 技术深析:衡石Agentic BI的架构革命与核心技术突破
  • openLCA完整安装与使用终极指南:免费开源的生命周期评估解决方案
  • 适配新的gps模块,在Android系统中注意哪些问题
  • AI赋能性能优化:让快马平台的智能模型帮你重构高性能代码
  • insightface进行视频中人脸识别
  • 【花雕学编程】行空板 K10 部署 MimiClaw 嵌入式 AI Agent 全指南(适配逻辑+命令全集+测试实践)
  • 2025苏州GEO大模型AI优化服务白皮书
  • 零基础看懂计算机视觉:让机器像人一样“看见”世界,原来原理这么简单
  • PvZ Toolkit:3步解锁植物大战僵尸终极游戏增强工具,打造完全自定义体验
  • SEO_本地中小企业快速见效的SEO推广技巧
  • 【PCIe验证每日学习·Day25】PCIe 电源管理机制(L0s/L1/L2/L3)全解析
  • AI 究竟让年轻人更有优势,还是更难立足?
  • 企业网站SEO优化需要做哪些内容优化_如何进行企业网站的SEO优化
  • DeepSeek可以解决什么问题?
  • 告别手动配置:用快马ai脚本实现openclaw一键式高效部署
  • 探索Wand-Enhancer:开源工具实现WeMod功能解锁与安全实践指南
  • 【深伪检测论文阅读 第一期】Triple-modality interaction for deepfake detection on zero-shot identity​
  • SQL视图如何实现动态过滤_通过SQL存储过程调用视图
  • ComfyUI-Manager架构设计与企业级节点管理优化方案