服务枪支未启动代码=退出,状态= 203/exec

发布于 2025-02-13 23:31:02 字数 1802 浏览 2 评论 0原文

我正在尝试在亚马逊的红帽EC2 VM上配置枪支服务。

我创建了SERCVICE文件,但是当我运行它并检查状态时,它告诉我它失败了:

[Unit]  

Description=Gunicorn instance for a simple hello world app 

After=network.target

[Service] 

User=ec2-user

Group=nginx

WorkingDirectory=/home/ec2-user/webserverflask 

Environment="PATH=/home/ec2-user/webserverflask/venv/bin" 

ExecStart=/home/ec2-user/webserverflask/venv/bin/gunicorn --workers 3
--bind unix:webserverflask.sock -m 007 wsgi 

Restart=always


[Install] 

WantedBy=multi-user.target

错误消息:

●WebServer.Service-简单Hello World App的Gunicorn实例
已加载:已加载(/etc/systemd/system/webserver.service; enabled; vendor 预设:禁用)活动:失败(结果:出口代码) 2022-07-06 19:31:08 UTC; 20H前主PID:25957(Code =退出, 状态= 203/exec)

7月6日19:31:08 IP-172-31-95-13.ec2.internal Systemd [1]: WebServer.Service:退出主要进程,Code =已退出,状态= 203/exec 7月6日19:31:08 IP-172-31-95-13.ec2.internal Systemd [1]: WebServer.Service:结果“出口代码”失败。 7月6日19:31:08 IP-172-31-95-13.EC2.ETERTER SYSTERSD [1]:WEBSERVER.SERVICE:服务 RESTARTSEC = 100ms过期,调度重新启动。 7月6日19:31:08 IP-172-31-95-13.EC2.ETERTER SYSTERSD [1]:WEBSERVER.SERVICE:计划 重新启动工作,重新启动计数器在5月5日。 IP-172-31-95-13.EC2.ETERTER SYSTERSD [1]:停止Gunicorn实例 一个简单的Hello World应用程序。 7月6日19:31:08 IP-172-31-95-13.ec2.internal SystemD [1]:Weberver.Service:启动请求重复太快。七月 06 19:31:08 IP-172-31-95-13.ec2.internal Systemd [1]: WebServer.Service:结果“出口代码”失败。 7月6日19:31:08 IP-172-31-95-13.EC2.Internal Systemd [1]:未能启动gunicorn 一个简单的Hello World应用程序。

这是我的WSGI:

from app import app as application
if __name__ == "__main__":
    app.run()

烧瓶应用程序:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == "__main__":
    app.run()

I am trying to configure a gunicorn service on an Red hat EC2 vm of amazon.

I created the sercvice file, but when I run it and check the status it tells me that it failed:

[Unit]  

Description=Gunicorn instance for a simple hello world app 

After=network.target

[Service] 

User=ec2-user

Group=nginx

WorkingDirectory=/home/ec2-user/webserverflask 

Environment="PATH=/home/ec2-user/webserverflask/venv/bin" 

ExecStart=/home/ec2-user/webserverflask/venv/bin/gunicorn --workers 3
--bind unix:webserverflask.sock -m 007 wsgi 

Restart=always


[Install] 

WantedBy=multi-user.target

The error message:

● webserver.service - Gunicorn instance for a simple hello world app
Loaded: loaded (/etc/systemd/system/webserver.service; enabled; vendor
preset: disabled) Active: failed (Result: exit-code) since Wed
2022-07-06 19:31:08 UTC; 20h ago Main PID: 25957 (code=exited,
status=203/EXEC)

Jul 06 19:31:08 ip-172-31-95-13.ec2.internal systemd[1]:
webserver.service: Main process exited, code=exited, status=203/EXEC
Jul 06 19:31:08 ip-172-31-95-13.ec2.internal systemd[1]:
webserver.service: Failed with result 'exit-code'. Jul 06 19:31:08
ip-172-31-95-13.ec2.internal systemd[1]: webserver.service: Service
RestartSec=100ms expired, scheduling restart. Jul 06 19:31:08
ip-172-31-95-13.ec2.internal systemd[1]: webserver.service: Scheduled
restart job, restart counter is at 5. Jul 06 19:31:08
ip-172-31-95-13.ec2.internal systemd[1]: Stopped Gunicorn instance for
a simple hello world app. Jul 06 19:31:08 ip-172-31-95-13.ec2.internal
systemd[1]: webserver.service: Start request repeated too quickly. Jul
06 19:31:08 ip-172-31-95-13.ec2.internal systemd[1]:
webserver.service: Failed with result 'exit-code'. Jul 06 19:31:08
ip-172-31-95-13.ec2.internal systemd[1]: Failed to start Gunicorn
instance for a simple hello world app.

and here is my wsgi:

from app import app as application
if __name__ == "__main__":
    app.run()

and flask app:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == "__main__":
    app.run()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

几度春秋 2025-02-20 23:31:02

我设法解决了这个问题。
如果有人在尝试使用Internet教程部署烧烤枪的同时遇到了同样的问题,这是我的答案:

问题是枪支文件无法访问,我仍然不知道为什么,但是我设法解决了问题通过将枪支移至/usr/local/bin/gunicorn

,我的服务文件现在看起来像这样:

[Unit]
Description=Gunicorn instance for a simple hello world app
After=network.target

[Service]
User=ec2-user
Group=nginx
ExecStart=/usr/local/bin/gunicorn --workers 3 --chdir /home/ec2-user --bind unix                                                                                 :webserverflask.sock -m 007 webserverflask.wsgi


[Install]
WantedBy=multi-user.target

I managed to solve the issue.
If anyone had the same issue while trying to deploy a flask gunicorn using the tutorials on internet, here is my answer:

The problem was that the gunicorn file wasn't accessible, I still don't know why but I managed to fix the issue by moving gunicorn to /usr/local/bin/gunicorn

So my service file look like this now:

[Unit]
Description=Gunicorn instance for a simple hello world app
After=network.target

[Service]
User=ec2-user
Group=nginx
ExecStart=/usr/local/bin/gunicorn --workers 3 --chdir /home/ec2-user --bind unix                                                                                 :webserverflask.sock -m 007 webserverflask.wsgi


[Install]
WantedBy=multi-user.target
谈情不如逗狗 2025-02-20 23:31:02

我将通过尝试手动运行execstart命令来开始调试,然后查看该命令是否有效(或您获得的错误):

$ cd /home/ec2-user/webserverflask
$ /home/ec2-user/webserverflask/venv/bin/gunicorn --workers 3 --bind unix:webserverflask.sock -m 007 wsgi 

I would start debugging by trying to run the ExecStart command manually, and see if that works (or what error you get):

$ cd /home/ec2-user/webserverflask
$ /home/ec2-user/webserverflask/venv/bin/gunicorn --workers 3 --bind unix:webserverflask.sock -m 007 wsgi 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文