Take it slow. Don't rush.

I am awake for about another 45 minutes.

We are going to start with:

$HOME/webapps/django_math

because that is what you supplied the last Apache configuration file.

Read through all the steps below first. Only when you believe you
understand things then consider doing anything. If you don't understand
something then ask.

Be tolerant of minor mistakes and see if you can work out what I stuffed
up. For example if a path is wrong.

If when get to point where have stopped old site and trying to run new,
if there is an issue, then ensure new is stopped and restore things so
old runs again while work out what issue was.

The steps are:

1. Install a newer version of mod_wsgi than you currently have. This is a
development version which has a few new options we are going to need to
match how WebFaction handles logfiles. I added them specifically to support
your setup. :-)

To do this run:

pip2.7 install -U 
https://github.com/GrahamDumpleton/mod_wsgi/archive/develop.zip

Test it is installed okay by running:

mod_wsgi-express

with no arguments. It should output the usage.

2. Create a file called:

$HOME/webapps/django_math/express-config

In it place:

#!/bin/sh

APPL_NAME=django_math
SITE_NAME=mathsite
SITE_PORT=20241

PYTHON_VERSION=2.7

SITE_ROOT=${HOME}/webapps/${APPL_NAME}

LOG_DIR=$HOME/logs/user
LOG_FORMAT="%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" 
\"%{User-Agent}i\""

cd ${SITE_ROOT}

mod_wsgi-express setup-server \
    --working-directory ${SITE_NAME} \
    --server-root express \
    --port ${SITE_PORT} \
    --log-directory ${LOG_DIR} \
    --access-log --access-log-format "${LOG_FORMAT}" \
    --access-log-name access_${APPL_NAME}.log \
    --error-log-name error_${APPL_NAME}.log \
    --python-path ${SITE_ROOT}/lib/python${PYTHON_VERSION} \
    $SITE_NAME/$SITE_NAME/wsgi.py

### End express-config.

3. Make the express-config script executable.

chmod +x express-config

This script is what is going to be used to generate the Apache configuration
for you and setup all the managements scripts for starting up and shutting
down Apache.

I have got you to create a script for it so the options you use are
recorded and you don't forget them. You may want to tweak the configuration
at some point later by adding more options. Such as to change number of
processes and threads or timeout values.

Once this is working, then you can duplicate the script to equivalent
location for your second application and change the APPL_NAME, SITE_NAME
and SITE_PORT settings to match and follow similar procedure.

4. Run the express-config script:

cd $HOME/webapps/django_math
./express-config

This should output something that looks like:

Server URL         : http://localhost:20241/
Server Root        : /home/simamura/webapps/django_math/express
Server Conf        : /home/simamura/webapps/django_math/express/httpd.conf
Error Log File     : /home/simamura/logs/user/error_django_math.log
Access Log File    : /home/simamura/logs/user/access_django_math.log
Environ Variables  : /home/simamura/webapps/django_math/express/envvars
Control Script     : /home/simamura/webapps/django_math/express/apachectl
Request Capacity   : 5 (1 process * 5 threads)
Request Timeout    : 60 (seconds)
Queue Backlog      : 100 (connections)
Queue Timeout      : 45 (seconds)
Server Capacity    : 20 (event/worker), 20 (prefork)
Server Backlog     : 500 (connections)
Locale Setting     : en_US.UTF-8

This has not run Apache at this point, it only generates the configuration.

To see what it has generated, look inside the 'express' subdirectory. That
is, as listed against 'Server Root'.

Look around in here to see what is generated, but never modify any files in
here. Well actually, it is possible to modify the 'envvars' file as that one
file will not be overridden if you run the script again, where as other
files in the directory will be, but right now I don't think we need to
modify 'envvars'.

In short, always modify express-config and rerun it to modify the
configuration, never edit generated configuration directly as you will
loose the changes if express-config is run again.

5. We now need to test this runs up your application okay.

Unfortunately WebFaction assigns specific port numbers to you to use and
so it is a bit hard to choose a random port just to test if this will
now start up. We therefore actually need to stop your existing site first
so we can run this.

The first step you need to do here is stop WebFaction from restarting
your existing site when you stop it.

To do this you need to edit the crontab file for your account and comment
out the cronjob entry for the site.

So first up run:

crontab -l

This will yield:

15,35,55 * * * * ~/webapps/django_math/apache2/bin/start
10,30,50 * * * * ~/webapps/django_gradis/apache2/bin/start

You are going to comment out the entry for 'django_math'.

To do that run:

crontab -e

This will throw you into 'vi', 'vim', or whatever else may be set as your
editor.

Edit the file so it looks like:

# 15,35,55 * * * * ~/webapps/django_math/apache2/bin/start
10,30,50 * * * * ~/webapps/django_gradis/apache2/bin/start

Save the file and exit the editor. This will stop cron from restarting
your existing Apache instance for 'django_math' when it is stopped.

6. Stop your existing Apache instance for 'django_math'.

Run:

$HOME/webapps/django_math/apache2/bin/stop

7. Start up the mod_wsgi-express generated version of the Apache
configuration.

This is done by running the 'apachectl' script listed under 'Control Script'
in what was generated by 'express-config'.

When run it MUST be given the 'start' argument.

Run:

$HOME/webapps/django_math/express/apachectl start

8. Attempt to access your web site using its external URL.

If that doesn't work, then we need to shutdown the new Apache instance
by running:

$HOME/webapps/django_math/express/apachectl stop

That is, same control script but with the 'stop' argument.

The restart your old Apache instance to get that running again.

$HOME/webapps/django_math/apache2/bin/start

Reinstate the controb entry, by running:

crontab -e

and restoring the file to:

15,35,55 * * * * ~/webapps/django_math/apache2/bin/start
10,30,50 * * * * ~/webapps/django_gradis/apache2/bin/start

Check with:

crontab -l

that it is back how it was.

Now look in:

$HOME/logs/user/error_django_math.log

and if it has any errors from when new Apache instance was started up
then send it to me so I can work out what went wrong.

Skip step 9.

9. If step 8 all worked fine and your site is working okay and all your
testing shows it is all perfect, including static file assets and you
want to now run it permanently, edit the crontab file again and add in
command to ensure that new Apache is started.

Run:

crontab -e

change it to read:

#15,35,55 * * * * ~/webapps/django_math/apache2/bin/start
15,35,55 * * * * ~/webapps/django_math/express/apachectl start
10,30,50 * * * * ~/webapps/django_gradis/apache2/bin/start

Thus, old command still commented out and new one which runs:

~/webapps/django_math/express/apachectl start

When run for a while, use 'ps auxwww' to look for process entries with names:

httpd (mod_wsgi-express)
(wsgi:localhost:20241:XXX)

where XXX is your UNIX account uid.

See how much memory they are using.

If there isn't a great deal of difference to before, then it is
questionable as to whether the memory issue is due to Apache. Would still
be interested in what memory sizes you are getting for processes.

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to