Skip to main content
 首页 » 编程设计

python之gunicorn之如果从 shell 脚本执行则不获取配置文件

2025年05月04日8bonelee

这是我的 shell 脚本的代码:

#!/bin/bash   
source /path/to/active 
gunicorn_django -c /path/to/conf.py -D 

上面的 sh 文件在执行时启动了 gunicorn 进程,但它没有使用配置文件。

但是,如果我直接从命令行执行命令,比如

gunicorn_django -c path/to/conf.py -D 

然后它正在使用配置文件。

此外,在 sh 文件中,如果我直接提供选项,如 -w 3 -error-logfile 等。那么它正在接受选项。

请您参考如下方法:

使用这个脚本,对我有用:

#!/bin/bash   
source /path/to/active 
gunicorn_django -c $(pwd)/path/to/conffilefrom/presentworkingdirectory -D