You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署Django应用时supervisor执行gunicorn_start报ENOEXEC错误如何解决

问题原因及解决步骤

ENOEXEC报错本质是系统无法正常执行指定的脚本文件,按以下顺序排查即可解决:

1. 给脚本添加可执行权限

执行以下命令为gunicorn_start脚本授予执行权限:

chmod +x /home/clouditech/bin/gunicorn_start

2. 修复脚本换行符格式

如果该脚本是在Windows系统下编辑后上传到Linux服务器的,会存在换行符不兼容问题,导致shebang声明失效,执行以下命令转换格式:

# 先安装dos2unix(已安装可跳过)
apt install dos2unix
# 转换脚本格式
dos2unix /home/clouditech/bin/gunicorn_start

3. 补全sh命令的绝对路径

修改supervisor配置文件/etc/supervisor/conf.d/clouditech.conf中的command参数,使用sh的绝对路径避免环境变量读取异常:

[program:clouditech]
command = /bin/sh /home/clouditech/bin/gunicorn_start
user=clouditech
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/home/clouditech/logs/gunicorn-error.log

4. 验证依赖路径和权限

  • 确认目录存在:/home/clouditech/run、/home/clouditech/logs两个目录必须存在,且所属用户和用户组为clouditech,可执行以下命令创建并授权:
mkdir -p /home/clouditech/run /home/clouditech/logs
chown -R clouditech:clouditech /home/clouditech/run /home/clouditech/logs
  • 确认虚拟环境路径正确:脚本中使用的../bin/activate、../bin/gunicorn对应路径为/home/clouditech/bin/activate和/home/clouditech/bin/gunicorn,需确认两个文件真实存在。

5. 手动验证脚本可执行性

切换到clouditech用户手动执行脚本,确认无报错:

sudo -u clouditech /home/clouditech/bin/gunicorn_start

6. 重载supervisor配置生效

所有修改完成后执行以下命令更新supervisor配置:

supervisorctl reread
supervisorctl update
supervisorctl restart clouditech

内容的提问来源于stack exchange,提问作者sam hassan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 20:48:01