HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   HOWTO-Related Questions (http://www.howtoforge.com/forums/forumdisplay.php?f=2)
-   -   The Perfect SpamSnake - Ubuntu Jeos 10.04 - Nginx, uWSGI & Baruwa (http://www.howtoforge.com/forums/showthread.php?t=50450)

Drex56 10th December 2010 15:03

The Perfect SpamSnake - Ubuntu Jeos 10.04 - Nginx, uWSGI & Baruwa
 
Hi All,

wondering if any of you can give me a hand as im slowly frying my brain with this. My problem is as follows, I have setup MailScanner no problems, works fine, its just the Nginx, uWsgi and baruwa combination that are giving me headaches. I know im not using the prescribed 10.10 but it wasn't an option and I quite like LTS. Basically I have setup as per the how-to (associated conf and ini files below) and all I get at the moment is:

uWSGI Error
wsgi application not found


/etc/uwsgi/uwsgi-python2.6/baruwa.ini:

[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()

/etc/nginx/sites-available/baruwa.conf:

server {
listen 80;
server_name exam.example.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;
}
}

One thing that is obvious is the socket, before everyone shouts at once a
"ls /var/run/uwsgi/uwsgi-python2.6/baruwa" returns:

pid socket

Hence the change from 'baruwa.sock' to 'socket'.

Please let me know if there is anymore information you need or if you would like me to test anything.

Thanks Muchly,

Drex

Rocky 11th December 2010 00:07

Hey,

Try this in your baruwa.ini:
pythonpath = /usr/share/pyshared/baruwa/

Restart nginx and uwsgi.

Let me know if that worked.

Drex56 11th December 2010 17:47

Hi Rocky,

Thanks for the suggestion, unfortunately, still a no-go, I have noticed this, however, when I restart uwsgi:

Code:

# /etc/init.d/uwsgi-python2.6 restart
 * Restarting WSGI server(s) uwsgi-python2.6
                                    /etc/init.d/uwsgi-python2.6: 109: Bad substitution
                                    /etc/init.d/uwsgi-python2.6: 109: Bad substitution
                                    /etc/init.d/uwsgi-python2.6: 109: Bad substitution

Is this anything that I should be worrying about? related at all?

Anyway my
Code:

/etc/uwsgi/uwsgi-python2.6/baruwa.ini
now looks like this:

Code:

[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()
  pythonpath = /usr/share/pyshared/baruwa/

Oh regarding the above uwsgi-python error, my
Code:

/etc/init.d/uwsgi-python2.6
looks like this:

Code:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          uwsgi-python2.6
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:    $local_fs $remote_fs $network
# Default-Start:    2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop uwsgi-python2.6 server instance(s)
### END INIT INFO

# Author: Leonid Borisenko <leo.borisenko@gmail.com>

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="WSGI server(s)"            # Introduce a short description here
NAME="uwsgi-python2.6"          # Introduce the short server's name here
DAEMON=/usr/bin/uwsgi-python2.6  # Introduce the server's location here
SCRIPTNAME=/etc/init.d/$NAME
CONFDIR=/etc/uwsgi/uwsgi-python2.6

RUNDIR=/var/run/uwsgi
UWSGI_RUNDIR=$RUNDIR/uwsgi-python2.6

LOGDIR=/var/log/uwsgi
UWSGI_LOGDIR=$LOGDIR/uwsgi-python2.6
LOG_FILENAME_SUFFIX=uwsgi-python2.6

# Exit if the package is not installed
[ -x $DAEMON ] || exit 0

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

# Define supplementary functions
. /usr/lib/uwsgi/init/snippets
. /usr/lib/uwsgi/init/do_command

WHAT=$1
shift
case "$WHAT" in
  start)
    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
    do_command "$WHAT" "$@"
    RETVAL="$?"
    [ "$VERBOSE" != no ] && log_end_msg "$RETVAL"
  ;;

  stop)
    [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
    do_command "$WHAT" "$@"
    RETVAL="$?"
    [ "$VERBOSE" != no ] && log_end_msg "$RETVAL"
  ;;

  status)
    if [ -z "$1" ]; then
      [ "$VERBOSE" != no ] && log_failure_msg "which one?"
    else
      status_of_proc -p $(find_specific_pidfile $1) "$DAEMON" "$NAME" \
        && exit 0 \
        || exit $?
    fi
  ;;

  reload)
    [ "$VERBOSE" != no ] && log_daemon_msg "Reloading $DESC" "$NAME"
    do_command "$WHAT" "$@"
    RETVAL="$?"
    [ "$VERBOSE" != no ] && log_end_msg "$RETVAL"
  ;;

  force-reload)
    [ "$VERBOSE" != no ] && log_daemon_msg "Forced reloading $DESC" "$NAME"
    do_command "$WHAT" "$@"
    RETVAL="$?"
    [ "$VERBOSE" != no ] && log_end_msg "$RETVAL"
  ;;

  restart)
    [ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME"
    CURRENT_VERBOSE=$VERBOSE
    VERBOSE=no
    do_command stop "$@"
    VERBOSE=$CURRENT_VERBOSE
    case "$?" in
      0)
        do_command start "$@"
        RETVAL="$?"
        [ "$VERBOSE" != no ] && log_end_msg "$RETVAL"
      ;;
      *)
        # Failed to stop
        [ "$VERBOSE" != no ] && log_end_msg 1
      ;;
    esac
  ;;

  *)
    echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload}" >&2
    exit 3
  ;;
esac

Thanks Muchly,

Drex

Rocky 11th December 2010 20:11

Change the socket back to baruwa.sock, try to restart and see what happens. I haven't seen that error and not sure why it's happening right now. I'll dig some more. Have you altered anything with uwsgi/nginx after the setup beside the ini and conf files?

Drex56 11th December 2010 22:30

Hi Rocky,

Well changed baruwa.ini and baruwa.conf back to baruwa.sock and restart bout uWSGI and nginx (in that order) and now have a lovely "502 gateway" error.

This is the error I initailly cam across when I started everything up which led me to change the socket to "socket".

Other than that everything is set as per the guide.

Thanks for all your help thus far, I spent a long time trying to google the error before posting and couldn't find anything or relevance on it.

Thanks,

Drex

Rocky 12th December 2010 04:43

Does this folder exist in your setup?
/var/run/uwsgi/uwsgi-python2.6/baruwa/

Change the socket line to /tmp/baruwa.sock in your ini and conf file and see what happens.

What's in your uwsgi-python2.6 log file?

Drex56 13th December 2010 11:49

Hi Rocky,

Yes, /var/run/uwsgi/uwsgi-python2.6/baruwa does exist and has the PID and the Socket files inside it.

I changed the 2 baruwa files and still no joy.

Am i correct in assuming that the /etc/uwsgi/uwsgi-python2.6/baruwa.ini file sets the socket and pid locations? If this is correct it would assume that the baruwa.ini is not being read correctly?

Thanks for all your help thus far,

Drex

Drex56 13th December 2010 12:01

Hi Rocky,

Here is my log file:

Code:

Sat Dec 11 20:26:06 2010 - SIGINT/SIGQUIT received...killing workers...
Sat Dec 11 20:26:07 2010 - goodbye to uWSGI.
Sat Dec 11 20:26:08 2010 - *** Starting uWSGI 0.9.6.5 (64bit) on [Sat Dec 11 20:26:08 2010] ***
Sat Dec 11 20:26:08 2010 - compiled with version: 4.4.3
Sat Dec 11 20:26:08 2010 - Python version: 2.6.5 (r265:79063, Apr 16 2010, 14:15:55)
[GCC 4.4.3]
Sat Dec 11 20:26:08 2010 - writing pidfile to /var/run/uwsgi/uwsgi-python2.6/baruwa/pid
Sat Dec 11 20:26:08 2010 - uWSGI running as root, you can use --uid/--gid/--chroot options
Sat Dec 11 20:26:08 2010 - setgid() to 33
Sat Dec 11 20:26:08 2010 - setuid() to 33
Sat Dec 11 20:26:08 2010 - your memory page size is 4096 bytes
Sat Dec 11 20:26:08 2010 - allocated 648 bytes (0 KB) for 1 request's buffer.
Sat Dec 11 20:26:08 2010 - binding on UNIX socket: /var/run/uwsgi/uwsgi-python2.6/baruwa/socket
Sat Dec 11 20:26:08 2010 - your server socket listen backlog is limited to 64 connections
Sat Dec 11 20:26:08 2010 - initializing hooks...Sat Dec 11 20:26:08 2010 - done.
Sat Dec 11 20:26:08 2010 - *** uWSGI is running in multiple interpreter mode ***
Sat Dec 11 20:26:08 2010 - spawned uWSGI master process (pid: 21956)
Sat Dec 11 20:26:08 2010 - max_ovec = 0
Sat Dec 11 20:26:08 2010 - spawned uWSGI worker 1 (pid: 21957)
Sat Dec 11 20:26:08 2010 - spawned uWSGI worker 2 (pid: 21958)
Mon Dec 13 09:34:08 2010 - SIGINT/SIGQUIT received...killing workers...
Mon Dec 13 09:34:10 2010 - goodbye to uWSGI.
Mon Dec 13 09:34:11 2010 - *** Starting uWSGI 0.9.6.5 (64bit) on [Mon Dec 13 09:34:11 2010] ***
Mon Dec 13 09:34:11 2010 - compiled with version: 4.4.3
Mon Dec 13 09:34:11 2010 - Python version: 2.6.5 (r265:79063, Apr 16 2010, 14:15:55)
[GCC 4.4.3]
Mon Dec 13 09:34:11 2010 - writing pidfile to /var/run/uwsgi/uwsgi-python2.6/baruwa/pid
Mon Dec 13 09:34:11 2010 - uWSGI running as root, you can use --uid/--gid/--chroot options
Mon Dec 13 09:34:11 2010 - setgid() to 33
Mon Dec 13 09:34:11 2010 - setuid() to 33
Mon Dec 13 09:34:11 2010 - your memory page size is 4096 bytes
Mon Dec 13 09:34:11 2010 - allocated 648 bytes (0 KB) for 1 request's buffer.
Mon Dec 13 09:34:11 2010 - binding on UNIX socket: /var/run/uwsgi/uwsgi-python2.6/baruwa/socket
Mon Dec 13 09:34:11 2010 - your server socket listen backlog is limited to 64 connections
Mon Dec 13 09:34:11 2010 - initializing hooks...Mon Dec 13 09:34:11 2010 - done.
Mon Dec 13 09:34:11 2010 - *** uWSGI is running in multiple interpreter mode ***
Mon Dec 13 09:34:11 2010 - spawned uWSGI master process (pid: 25245)
Mon Dec 13 09:34:11 2010 - max_ovec = 0
Mon Dec 13 09:34:11 2010 - spawned uWSGI worker 1 (pid: 25248)
Mon Dec 13 09:34:11 2010 - spawned uWSGI worker 2 (pid: 25251)

Please let me know if you would like me to do anything else.

Regards,

Drex.

Drex56 13th December 2010 12:55

Hi Rocky,

I changed the socket back to /var/run/uwsgi/uwsgi-python2.6/baruwa/socket and restart uwsgi and nginx, my logfile now looks like this:

Code:

Mon Dec 13 10:30:45 2010 - SIGINT/SIGQUIT received...killing workers...
Mon Dec 13 10:30:47 2010 - goodbye to uWSGI.
Mon Dec 13 10:30:47 2010 - *** Starting uWSGI 0.9.6.5 (64bit) on [Mon Dec 13 10:30:47 2010] ***
Mon Dec 13 10:30:47 2010 - compiled with version: 4.4.3
Mon Dec 13 10:30:47 2010 - Python version: 2.6.5 (r265:79063, Apr 16 2010, 14:15:55)
[GCC 4.4.3]
Mon Dec 13 10:30:47 2010 - writing pidfile to /var/run/uwsgi/uwsgi-python2.6/baruwa/pid
Mon Dec 13 10:30:47 2010 - uWSGI running as root, you can use --uid/--gid/--chroot options
Mon Dec 13 10:30:47 2010 - setgid() to 33
Mon Dec 13 10:30:47 2010 - setuid() to 33
Mon Dec 13 10:30:47 2010 - your memory page size is 4096 bytes
Mon Dec 13 10:30:47 2010 - allocated 648 bytes (0 KB) for 1 request's buffer.
Mon Dec 13 10:30:47 2010 - binding on UNIX socket: /var/run/uwsgi/uwsgi-python2.6/baruwa/socket
Mon Dec 13 10:30:47 2010 - your server socket listen backlog is limited to 64 connections
Mon Dec 13 10:30:47 2010 - initializing hooks...Mon Dec 13 10:30:47 2010 - done.
Mon Dec 13 10:30:47 2010 - *** uWSGI is running in multiple interpreter mode ***
Mon Dec 13 10:30:47 2010 - spawned uWSGI master process (pid: 30234)
Mon Dec 13 10:30:47 2010 - max_ovec = 0
Mon Dec 13 10:30:47 2010 - spawned uWSGI worker 1 (pid: 30236)
Mon Dec 13 10:30:47 2010 - spawned uWSGI worker 2 (pid: 30237)
[pid: 30237|app: -1|req: -1/1] xxx.xxx.xxx.xxx () {46 vars in 961 bytes} [Mon Dec 13 10:30:52 2010] GET / => generated 46 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 async switches on async core 0)
[pid: 30236|app: -1|req: -1/2] xxx.xxx.xxx.xxx () {46 vars in 961 bytes} [Mon Dec 13 10:30:55 2010] GET / => generated 46 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 async switches on async core 0)
[pid: 30237|app: -1|req: -1/3] xxx.xxx.xxx.xxx () {46 vars in 961 bytes} [Mon Dec 13 10:30:56 2010] GET / => generated 46 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 async switches on async core 0)
[pid: 30236|app: -1|req: -1/4] 58.218.204.110 () {34 vars in 459 bytes} [Mon Dec 13 10:40:49 2010] GET /judge.php => generated 46 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 async switches on async core 0)
Mon Dec 13 10:07:45 2010 - SIGINT/SIGQUIT received...killing workers...
Mon Dec 13 10:07:46 2010 - goodbye to uWSGI.
Mon Dec 13 10:07:46 2010 - *** Starting uWSGI 0.9.6.5 (64bit) on [Mon Dec 13 10:07:46 2010] ***
Mon Dec 13 10:07:46 2010 - compiled with version: 4.4.3
Mon Dec 13 10:07:46 2010 - Python version: 2.6.5 (r265:79063, Apr 16 2010, 14:15:55)
[GCC 4.4.3]
Mon Dec 13 10:07:46 2010 - writing pidfile to /var/run/uwsgi/uwsgi-python2.6/baruwa/pid
Mon Dec 13 10:07:46 2010 - uWSGI running as root, you can use --uid/--gid/--chroot options
Mon Dec 13 10:07:46 2010 - setgid() to 33
Mon Dec 13 10:07:46 2010 - setuid() to 33
Mon Dec 13 10:07:46 2010 - your memory page size is 4096 bytes
Mon Dec 13 10:07:46 2010 - allocated 648 bytes (0 KB) for 1 request's buffer.
Mon Dec 13 10:07:46 2010 - binding on UNIX socket: /var/run/uwsgi/uwsgi-python2.6/baruwa/socket
Mon Dec 13 10:07:46 2010 - your server socket listen backlog is limited to 64 connections
Mon Dec 13 10:07:46 2010 - initializing hooks...Mon Dec 13 10:07:46 2010 - done.
Mon Dec 13 10:07:46 2010 - *** uWSGI is running in multiple interpreter mode ***
Mon Dec 13 10:07:46 2010 - spawned uWSGI master process (pid: 28202)
Mon Dec 13 10:07:46 2010 - max_ovec = 0
Mon Dec 13 10:07:46 2010 - spawned uWSGI worker 1 (pid: 28203)
Mon Dec 13 10:07:46 2010 - spawned uWSGI worker 2 (pid: 28205)
[pid: 28203|app: -1|req: -1/1] xxx.xxx.xxx.xxx () {46 vars in 961 bytes} [Mon Dec 13 10:07:55 2010] GET / => generated 46 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 async switches on async core 0)
[pid: 28205|app: -1|req: -1/2] xxx.xxx.xxx.xxx () {46 vars in 961 bytes} [Mon Dec 13 10:07:59 2010] GET / => generated 46 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 async switches on async core 0)
[pid: 28203|app: -1|req: -1/3] xxx.xxx.xxx.xxx () {46 vars in 961 bytes} [Mon Dec 13 10:08:00 2010] GET / => generated 46 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 async switches on async core 0)
[pid: 28205|app: -1|req: -1/4] xxx.xxx.xxx.xxx () {46 vars in 961 bytes} [Mon Dec 13 10:08:00 2010] GET / => generated 46 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 async switches on async core 0)
[pid: 28203|app: -1|req: -1/5] xxx.xxx.xxx.xxx () {46 vars in 961 bytes} [Mon Dec 13 10:08:00 2010] GET / => generated 46 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 async switches on async core 0)
[pid: 28205|app: -1|req: -1/6] xxx.xxx.xxx.xxx () {46 vars in 961 bytes} [Mon Dec 13 10:08:00 2010] GET / => generated 46 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 async switches on async core 0)
[pid: 28203|app: -1|req: -1/7] xxx.xxx.xxx.xxx () {46 vars in 961 bytes} [Mon Dec 13 10:30:16 2010] GET / => generated 46 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 async switches on async core 0)
[pid: 28205|app: -1|req: -1/8] xxx.xxx.xxx.xxx () {46 vars in 961 bytes} [Mon Dec 13 10:30:18 2010] GET / => generated 46 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 async switches on async core 0)


Drex56 14th December 2010 01:55

Hi Rocky,

I'VE FOUND THE PROBLEM!!!!! yey!

I've been playing with the command that the init.d script uses to start uwsgi. The script created this command line (That I found using ps):

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 -- /etc/uwsgi/uwsgi-python2.6/baruwa.ini
After much playing (and alot of faffing with folder creation and permissions!) the blindingly obvious came about, its missing "--INI" before it specifies the baruwa.ini file!!!

So.. my question now is, how do i get it to add it into the command line??? :confused:

Thanks for all your hard work and if I find the solution before yourself, I'll post it here!

Much Regards,

Drex


All times are GMT +2. The time now is 02:57.

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