Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > HOWTO-Related Questions

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 8th March 2011, 14:23
tuxic tuxic is offline
Junior Member
 
Join Date: Mar 2011
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
Default ubuntu jeos 10.10 spamsnake Bad Gateway baruwa.sock

Yesterday I followed this guide and got stuck on the following.

In a browser i keep getting : 502 Bad Gateway

What i'v read in the forums is that i could have multiple causes. I tried to eliminate them all.

Now it is down to the fact that uwsgi doesn't correctly read the ini file.

Here is the uwsgi startup line: (from ps ax)

Code:
/usr/bin/uwsgi-python2.6 --master --no-orphans --processes 2 --logdate --chmod-socket=660 --uid www-data --gid www-data --daemonize /var/log/uwsgi/uwsgi-python2.6/baruwa.uwsgi-python2.6.log --pidfile /var/run/uwsgi/uwsgi-python2.6/baruwa/pid --socket /var/run/uwsgi/uwsgi-python2.6/baruwa/socket --ini /etc/uwsgi/uwsgi-python2.6/baruwa.ini
The baruwa.ini is according to the guide containing:
Code:
socket = /var/run/uwsgi/uwsgi-python2.6/baruwa/baruwa.sock
also the nginx baruwa.conf

My uwsgi python log shows this:
Code:
[uWSGI] getting YAML configuration from /etc/uwsgi/uwsgi-python2.6/baruwa.ini
Tue Mar  8 14:10:49 2011 - *** Starting uWSGI 0.9.6.6 (64bit) on [Tue Mar  8 14:10:49 2011] ***
Tue Mar  8 14:10:49 2011 - compiled with version: 4.4.5
Tue Mar  8 14:10:49 2011 - Python version: 2.6.6 (r266:84292, Sep 15 2010, 16:41:53)
[GCC 4.4.5]
Tue Mar  8 14:10:49 2011 - writing pidfile to /var/run/uwsgi/uwsgi-python2.6/baruwa/pid
Tue Mar  8 14:10:49 2011 - uWSGI running as root, you can use --uid/--gid/--chroot options
Tue Mar  8 14:10:49 2011 - setgid() to 33
Tue Mar  8 14:10:49 2011 - setuid() to 33
Tue Mar  8 14:10:49 2011 - your memory page size is 4096 bytes
Tue Mar  8 14:10:49 2011 - allocated 648 bytes (0 KB) for 1 request's buffer.
Tue Mar  8 14:10:49 2011 - binding on UNIX socket: /var/run/uwsgi/uwsgi-python2.6/baruwa/socket
Tue Mar  8 14:10:49 2011 - your server socket listen backlog is limited to 64 connections
Tue Mar  8 14:10:49 2011 - initializing hooks...Tue Mar  8 14:10:49 2011 - done.
Tue Mar  8 14:10:49 2011 - spawned uWSGI master process (pid: 2222)
Tue Mar  8 14:10:49 2011 - max_ovec = 0
Tue Mar  8 14:10:49 2011 - spawned uWSGI worker 1 (pid: 2232)
Tue Mar  8 14:10:49 2011 - spawned uWSGI worker 2 (pid: 2233)
And nginx error.log shows this:
Code:
14:16:49 [crit] 2488#0: *1 connect() to unix:///var/run/uwsgi/uwsgi-python2.6/baruwa/baruwa.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.0.145

Everything is according to the guide with default install of ubuntu server 10.10

I would greatly appreciate any pointers.

Thx
Reply With Quote
Sponsored Links
  #2  
Old 8th March 2011, 14:45
topdog topdog is offline
Senior Member
 
Join Date: Jan 2008
Location: South Africa
Posts: 1,352
Thanks: 0
Thanked 153 Times in 150 Posts
Default

You are specifying the option --socket /var/run/uwsgi/uwsgi-python2.6/baruwa/socket on the command line which overrides the config file
__________________
----
http://www.topdog.za.net - Got Linux problems ? - I can help.
http://www.baruwa.org - Try it.
Reply With Quote
  #3  
Old 8th March 2011, 14:58
tuxic tuxic is offline
Junior Member
 
Join Date: Mar 2011
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by topdog View Post
You are specifying the option --socket /var/run/uwsgi/uwsgi-python2.6/baruwa/socket on the command line which overrides the config file
Thanks for your reply, are you sure this is default behaviour?

This is stated in the daemon options:
Code:
# Default socket location: /var/run/uwsgi/uwsgi-python2.6/<confname>/socket
# Tip: you could override '--socket' in configuration file.
Any clue where I can disable the default socket?
Reply With Quote
  #4  
Old 8th March 2011, 15:05
topdog topdog is offline
Senior Member
 
Join Date: Jan 2008
Location: South Africa
Posts: 1,352
Thanks: 0
Thanked 153 Times in 150 Posts
Default

Why the effort, there is nothing wrong with telling nginx there socket is /var/run/uwsgi/uwsgi-python2.6/baruwa/socket
__________________
----
http://www.topdog.za.net - Got Linux problems ? - I can help.
http://www.baruwa.org - Try it.
Reply With Quote
  #5  
Old 8th March 2011, 17:32
Rocky Rocky is offline
Senior Member
 
Join Date: Oct 2005
Posts: 553
Thanks: 14
Thanked 49 Times in 48 Posts
Default

Hey,

Looks like uwsgi is just skipping the socket statement and I'm sure you have /var/run/uwsgi/uwsgi-python2.6/baruwa directory
created. Must have been some changes with the latest revision.

Do as Andrew says and just point Nginx over to the socket. You should be fine from there.

__________________
Home of the SpamSnake
Reply With Quote
  #6  
Old 8th March 2011, 18:05
tuxic tuxic is offline
Junior Member
 
Join Date: Mar 2011
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by Rocky View Post
Hey,

Looks like uwsgi is just skipping the socket statement and I'm sure you have /var/run/uwsgi/uwsgi-python2.6/baruwa directory
created. Must have been some changes with the latest revision.

Do as Andrew says and just point Nginx over to the socket. You should be fine from there.

Thanks for the replies, I tried changing /etc/uwsgi/uwsgi-python2.6/baruwa.ini
and /etc/nginx/sites-enabled/baruwa.conf

added: /var/run/uwsgi/uwsgi-python2.6/baruwa/socket

Now I get a different error:

Code:
uWSGI Error

wsgi application not found
Any other suggestions?
Reply With Quote
  #7  
Old 8th March 2011, 18:23
Rocky Rocky is offline
Senior Member
 
Join Date: Oct 2005
Posts: 553
Thanks: 14
Thanked 49 Times in 48 Posts
Default

Do you have /etc/nginx/uwsgi_params?

Remember it has to be in this format in your nginx conf file:
uwsgi_pass unix:////var/run/uwsgi/uwsgi-python2.6/baruwa/socket;
__________________
Home of the SpamSnake

Last edited by Rocky; 8th March 2011 at 18:32.
Reply With Quote
  #8  
Old 8th March 2011, 18:57
tuxic tuxic is offline
Junior Member
 
Join Date: Mar 2011
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by Rocky View Post
Do you have /etc/nginx/uwsgi_params?

Remember it has to be in this format in your nginx conf file:
uwsgi_pass unix:////var/run/uwsgi/uwsgi-python2.6/baruwa/socket;
vim /etc/nginx/uwsgi_params
Code:
uwsgi_param  QUERY_STRING       $query_string;
uwsgi_param  REQUEST_METHOD     $request_method;
uwsgi_param  CONTENT_TYPE       $content_type;
uwsgi_param  CONTENT_LENGTH     $content_length;

uwsgi_param  REQUEST_URI        $request_uri;
uwsgi_param  PATH_INFO          $document_uri;
uwsgi_param  DOCUMENT_ROOT      $document_root;
uwsgi_param  SERVER_PROTOCOL    $server_protocol;

uwsgi_param  REMOTE_ADDR        $remote_addr;
uwsgi_param  REMOTE_PORT        $remote_port;
uwsgi_param  SERVER_PORT        $server_port;
uwsgi_param  SERVER_NAME        $server_name;
vim /etc/nginx/sites-enabled/baruwa.conf
Code:
server {
      listen 80;
      server_name spamsnaketest.com;
      root /usr/share/pyshared/baruwa;
      #main access log
      access_log  /var/log/nginx/access.log;
      #main error log
      error_log /var/log/nginx/error.log;
   location /static {
      root  /usr/share/pyshared/baruwa/static/;
      }
   # static resources
   location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
      {
      expires 30d;
      break;
      }
   location / {
uwsgi_pass unix:///var/run/uwsgi/uwsgi-python2.6/baruwa/socket;
include uwsgi_params;
      }
   }
This is with 3 backslashes according to the guide.

Any other suggestions, pulling my hair out over this.
Reply With Quote
  #9  
Old 8th March 2011, 19:27
Rocky Rocky is offline
Senior Member
 
Join Date: Oct 2005
Posts: 553
Thanks: 14
Thanked 49 Times in 48 Posts
Default

What version of uwsgi/nginx are you running?

So your uwsgi baruwa.ini should look like:
[uwsgi]
socket = /var/run/uwsgi/uwsgi-python2.6/baruwa/socket
master = true
processes = 2
env = DJANGO_SETTINGS_MODULE=baruwa.settings
module = django.core.handlers.wsgi:WSGIHandler()

Your nginx baruwa.conf should look like:
server {
listen 80;
server_name yourhostname;
root /usr/share/pyshared/baruwa;
#main access log
access_log /var/log/nginx/access.log;
#main error log
error_log /var/log/nginx/error.log;

location /static {
root /usr/share/pyshared/baruwa/static/;
}
# static resources

location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar |bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp| rtf|js)$
{
expires 30d;
break;
}
location /favicon.ico {
return 204;
}

location / {
uwsgi_pass unix:///var/run/uwsgi/uwsgi-python2.6/baruwa/socket;
include uwsgi_params;
}
}

And with these settings, you're still not able to hit the site?

Make sure and restart your system after making the configs to clear out any cache or so.

Before you made changes to the conf and ini to /socket, uwsgi was running fine, it was just nginx that needed a pointer. If we can undo the changes, get uwsgi to work, maybe we'll be able to get nginx up by trying a few things with it.
__________________
Home of the SpamSnake

Last edited by Rocky; 8th March 2011 at 19:39.
Reply With Quote
  #10  
Old 8th March 2011, 23:07
tuxic tuxic is offline
Junior Member
 
Join Date: Mar 2011
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
 
Default

Quote:
Originally Posted by Rocky View Post
What version of uwsgi/nginx are you running?
I'm on nginx version: nginx/0.9.5
and uWSGI 0.9.6.6 (64bit)

I tried your settings, rebooted and got to the baruwa startup page!!!
yeah!

So great, thanks greatly for your help. I can continue now with the guide.

Many thx
Tuxic
Reply With Quote
Reply

Bookmarks

Tags
baruwa, jeos, mailscanner, spamsnake, ubuntu

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu 10.10 SpamSnake .. 502 Bad Gateway RoboBunny HOWTO-Related Questions 7 25th February 2011 13:13
Intel 82815 Video Card & Ubuntu 8.10 harvey527 Kernel Questions 8 5th November 2010 14:51
Connection timed out on intermail outgoing mails gouravgarg Server Operation 6 5th March 2010 20:31
MailScanner trouble with DBD-MYSQL sergio.arnaldo Server Operation 11 26th August 2009 18:08
SpamSnake SpamAssassin not working? getrav HOWTO-Related Questions 5 23rd June 2008 23:02


All times are GMT +2. The time now is 00:04.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.