如何修复Django AWS EC2 Gunicorn ExecStart ExecStop结束错误?

时间:2018-02-16 16:27:12

标签: django amazon-web-services nginx amazon-ec2 gunicorn

我正在尝试将我的AWS Route 53域指向我的Django应用程序的EC2 IPv4公共IP,但我遇到了一些枪支问题。 奇怪的事情 是我获得了成功的nginx配置消息,但它不起作用。我已经在Route 53上创建了一个记录集。

错误: gunicorn.service:服务缺少ExecStart =和ExecStop =设置。拒

Settings.py:

ALLOWED_HOSTS = ['175.228.35.250', 'myapp.com']

gunicorn.service:

[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/my_app
ExecStart=/home/ubuntu/my_app/venv/bin/gunicorn --workers 3 --bind unix:/home/ubuntu/my_app/my_app.sock my_app.wsgi:application
[Install]
WantedBy=multi-user.target

Nginx代码:

server {
  listen 80;
  server_name 175.228.35.250 my_app.com www.my_app.com;
  location = /favicon.ico { access_log off; log_not_found off; }
  location /static/ {
      root /home/ubuntu/my_app;
  }
  location / {
      include proxy_params;
      proxy_pass http://unix:/home/ubuntu/my_app/my_app.sock;
  }
}

Nginx测试成功但是app还没有运行

ubuntu@ip-175-228-35-250:~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

1 个答案:

答案 0 :(得分:1)

任何关心的人。我登录系统并检查它。试图手动运行gunicorn它给我们一个不同的错误! Gunicorn和使用venv似乎很混乱。我重置了venv并重新安装了要求。系统现在尝试正确加载应用程序。打开调试,所以PandaNinja可以调试剩余的问题,因为应用程序现在崩溃了。

// The type of a subresource filtering rule.
enum RuleType {
  RULE_TYPE_UNSPECIFIED = 0;

  RULE_TYPE_COMMENT = 1;  // Comment rule.
  RULE_TYPE_URL = 2;      // Network level filtering rule based on URL pattern.
  RULE_TYPE_CSS = 3;      // Element hiding rule based on a CSS selector.
};

...

// Types of anchors that can be used to constrain where a URL pattern must
// begin/end in the URL in order to be considered a match.
enum AnchorType {
  ANCHOR_TYPE_UNSPECIFIED = 0;

  // Acts like a '*' wildcard at the respective end of a pattern.
  ANCHOR_TYPE_NONE = 1;
  // The pattern must match from the start/until the end of the URL.
  ANCHOR_TYPE_BOUNDARY = 2;
  // The pattern must match starting with the TLD+n of the URL's domain, but the
  // scheme and subdomains (if any) can be arbitrary.
  ANCHOR_TYPE_SUBDOMAIN = 3;
};
...