Astropy error when deploying an apache website (wsgi)

245 views
Skip to first unread message

qatar.exopl...@gmail.com

unread,
Oct 23, 2016, 7:43:12 AM10/23/16
to astropy-dev
Dear all,

I work remotely on different Mac through the world.
Each Mac host the same website on it (just with different data).
Recently, we renew our hardware, and all required modules for the website have been installed (I think).
The website use astropy.

CONFIGURATION:

Mac OSX 10.11.6
Python 2.7.10

astropy  1.2.1
numpy 1.11.2
scipy 0.13.0b1
matplotlib 1.3.1
WCSAxes 0.9
pytz 2013.7
scikit-image 0.12.3
pandas 0.19.0
objgraph-3.0.1
pyyaml-3.12
beautifulsoup 4.5.0
libxml2  2.9.4
h5py 2.6.0


PROBLEM:

I launch the httpd.conf with apachectl command. I have no errors, but when I try to go to my website (with a browser like firefox)
I got a proxy error, with the following error message in /var/log/apache2/error.log

/Library/Python/2.7/site-packages/astropy/config/configuration.py:541: ConfigurationMissingWarning: Configuration defaults will be used due to OSError:Could not find unix home directory to search for astropy config dir on None

WSGI module (it is installed) and loaded inside the httpd.conf file

So httpd.conf load site.conf,
site.conf launched httpd_wsgi

my site.wsgi launched a site.py wqhich contains the application and uses astropy.

Do you have please an idea how can I fix my problem ?
Please be clear in your answer, I am not an excellent programmer.

Thank very much in advance,
Nicolas Vilchez


Thomas Robitaille

unread,
Oct 23, 2016, 11:56:00 AM10/23/16
to astropy-dev mailing list
Hi Nicolas,

Evert Rol wrote up a document that describes how to get Astropy
working inside an Apache environment - in particular I think this
section is relevant for your issue:

https://gist.github.com/evertrol/d5739e17fb86ca4e65ea#configuring-for-astropy

I think the key is to explicitly set XDG_CONFIG_HOME and
XDG_CACHE_HOME to point to directories that Astropy can use.

Cheers,
Tom
> --
> You received this message because you are subscribed to the Google Groups
> "astropy-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to astropy-dev...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Qatar Exoplanet Survey

unread,
Oct 24, 2016, 6:18:42 AM10/24/16
to astro...@googlegroups.com
I already see this way on another website, but it was not clear as here. I will try and let you know.
Thank you so much for your help. I will report the issue soon.
cheers
nicolas

On Sun, Oct 23, 2016 at 6:55 PM, Thomas Robitaille <thomas.r...@gmail.com> wrote:
Hi Nicolas,

Evert Rol wrote up a document that describes how to get Astropy
working inside an Apache environment - in particular I think this
section is relevant for your issue:

https://gist.github.com/evertrol/d5739e17fb86ca4e65ea#configuring-for-astropy

I think the key is to explicitly set XDG_CONFIG_HOME and
XDG_CACHE_HOME to point to directories that Astropy can use.

Cheers,
Tom

> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "astropy-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/astropy-dev/0w2PWrNrnJU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to astropy-dev+unsubscribe@googlegroups.com.

Qatar Exoplanet Survey

unread,
Oct 25, 2016, 8:44:06 AM10/25/16
to astro...@googlegroups.com
Hello Tom, everybody,
So I tried all the day, and I still have the same issue in /var/log/apache2/error.log:

[Tue Oct 25 06:08:44.168910 2016] [:error] [pid 45065] /Library/Python/2.7/site-packages/astropy/config/configuration.py:541: ConfigurationMissingWarning: Configuration defaults will be used due to OSError:Could not find unix home directory to search for astropy config dir on None
[Tue Oct 25 06:08:44.169002 2016] [:error] [pid 45065]   warn(ConfigurationMissingWarning(msg))


Remember I am on a Mac OSX El Capitan 10.11.6

so I did :
$ mkdir -p /var/www/astropyconfig/astropy
$ mkdir -p /var/www/astropycache/astropy
$ chown -R www:www /var/www/astropyconfig
$ chown -R www:www /var/www/astropycache
Not chown -R apache:apache (as written is the doc) because on Mac user apache is not existing. I supposed www is the apache user (because, by default in my httpd.conf file, I have User _www Group _www)
cat /Library/Server/Web/Config/apache2/httpd.conf | grep User
# User/Group: The name (or #number) of the user/group to run httpd as.
User _www

cat /Library/Server/Web/Config/apache2/httpd.conf | grep Group
# User/Group: The name (or #number) of the user/group to run httpd as.
Group _www

and check on the mac:
sudo ls /var/db/dslocal/nodes/Default/users
_amavisd.plist            _devicemgr.plist        _krb_kadmin.plist        _nsurlstoraged.plist        _trustevaluationagent.plist
_appleevents.plist        _displaypolicyd.plist        _krb_kerberos.plist        _ondemand.plist            _unknown.plist
_appowner.plist            _distnote.plist            _krb_krbtgt.plist        _postfix.plist            _update_sharing.plist
_appserver.plist        _dovecot.plist            _krbfast.plist            _postgres.plist            _usbmuxd.plist
_ard.plist            _dovenull.plist            _krbtgt.plist            _qtss.plist            _uucp.plist
_assetcache.plist        _dpaudio.plist            _launchservicesd.plist        _sandbox.plist            _warmd.plist
_astris.plist            _eppc.plist            _lda.plist            _screensaver.plist        _webauthserver.plist
_atsserver.plist        _ftp.plist            _locationd.plist        _scsd.plist            _windowserver.plist
_avbdeviced.plist        _gamecontrollerd.plist        _lp.plist            _securityagent.plist        _www.plist
_calendar.plist            _geod.plist            _mailman.plist            _serialnumberd.plist        _wwwproxy.plist
_ces.plist            _iconservices.plist        _mbsetupuser.plist        _softwareupdate.plist        _xserverdocs.plist
_clamav.plist            _installassistant.plist        _mcxalr.plist            _spotlight.plist        com.apple.calendarserver.plist
_coreaudiod.plist        _installer.plist        _mdnsresponder.plist        _sshd.plist            daemon.plist
_coremediaiod.plist        _jabber.plist            _mysql.plist            _svn.plist            macports.plist
_cvmsroot.plist            _kadmin_admin.plist        _netbios.plist            _taskgated.plist        nobody.plist
_cvs.plist            _kadmin_changepw.plist        _netstatistics.plist        _teamsserver.plist        pipeline.plist
_cyrus.plist            _krb_anonymous.plist        _networkd.plist            _timezone.plist            root.plist
_devdocs.plist            _krb_changepw.plist        _nsurlsessiond.plist        _tokend.plist


So maybe it is _www not www user, ok, I did:

I  tried with _www user
chown -R _www:_www /var/www/astropyconfig/
chown -R _www:_www /var/www/astropycache/


Still the same issue as above....


Typically, what I am doing is that:

I launch a specific httpd.conf (I checked all my conf files, the configuration is OK)
sudo apachectl -f /Library/Server/Web/Config/apache2/httpd.conf -k restart

so the httpd_wsgi.conf is loaded by mysite.conf  with this line: Include /Library/Server/Web/Config/apache2/httpd_wsgi.conf

1)
the httpd_wsgi.conf:
WSGIDaemonProcess web_s1 user=pipeline group=qes threads=5
WSGIPassAuthorization On
WSGIScriptAlias / /Users/pipeline/software/qes2_pipeline/stage1_website/web_s1.wsgi

2)
the web_s1.wsgi:
import sys
sys.path.insert(0, '/Users/pipeline/software/qes2_pipeline/')
from stage1_website.web_s1 import application

3)
the web_s1.py

import sys
try:
    import envars
    os.environ.update(envvars)
except ImportError:
    sys.exit()

import datetime
import os
import glob
from astropy.io import fits
from collections import namedtuple
import flask
from flask.ext.basicauth import BasicAuth
from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware
from werkzeug.contrib.fixers import ProxyFix
from lib import calibration, db_tools, models
from api_website import web_api
from config import config
import tools
import time

import numpy as np
import matplotlib
from matplotlib import pyplot

DEFAULT_CONFIG = config.DEFAULT_CONFIG

# The sites that the web site will display, these need to be the site column from the sites column.
# The web page will only show information for sites in the database so at the telescopes because
# there will be no data for the other sites in those tables you can leave this variable as it is.
# But it will need to be edited if you decide to hide or add sites where data from multi sites exist
# in the database
SITES = ["KCAM", "NM", "TF", "CN"]

__author__ = 'Neil Parley, Dan Bramich'

app = flask.Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app)
app.debug = True
app.config['SECRET_KEY'] = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

app.config['BASIC_AUTH_USERNAME'] = config.web_password.user_name
app.config['BASIC_AUTH_PASSWORD'] = config.web_password.password
app.config['BASIC_AUTH_FORCE'] = True

basic_auth = BasicAuth(app)

web_api.API_ROOT = "api/"
web_api.DEFAULT_CONFIG = DEFAULT_CONFIG

application = DispatcherMiddleware(app, {
    '/api':     web_api.app
})

connection = db_tools.Connection(DEFAULT_CONFIG)

APP_LOCATION = os.path.dirname(os.path.abspath(__file__))


#####################################################################################
#Functions


def get_operation_logs(night):

BLABLABLABLA

####################################################################################
if __name__ == "__main__":
    run_simple('localhost', 5000, application,
               use_reloader=True, use_debugger=True, use_evalex=True)




4) I set envars.py as requested in the doc
$ cat envvars.py
envvars = {
    'XDG_CONFIG_HOME': '/var/www/astropyconfig',
    'XDG_CACHE_HOME': '/var/www/astropycache'
}


Am I correct ? did I do the proper thing to fix the error ?
Please let me know.

Another point, this web site works perfectly on other Mac OSX El Capitan through the world. (In practice 1 site for each observing station).
We just replace the hardware, so maybe I forgot to install something which is required for apache and astropy.

Please let me know, I am deep in the mess and desperate, I do not find any explanations or solutions ...
Thank you so much in advance.
best regards

Nicolas
PS: do not hesitate to ask me complementary infos. 




 


Qatar Exoplanet Survey

unread,
Oct 27, 2016, 2:40:53 AM10/27/16
to astro...@googlegroups.com
Hello dear astropy developpers,

Still no idea to fix my problem ?
thank you in advance

Qatar Exoplanet Survey

unread,
Oct 31, 2016, 3:16:57 AM10/31/16
to astro...@googlegroups.com
Hi all,
I still did not manage to fix this error.

So nobody has an idea ?
thank you
nicolas

On Thu, Oct 27, 2016 at 9:40 AM, Qatar Exoplanet Survey <qatar.exopl...@gmail.com> wrote:
Hello dear astropy developpers,

Still no idea to fix my problem ?
thank you in advance

Christoph Deil

unread,
Oct 31, 2016, 5:29:06 AM10/31/16
to astro...@googlegroups.com
Hi Nicolas,

the group of people running or at least familiar with Astropy via Apache on Mac is probably very small.
It might be that you’re the first one encountering this issue.

If you do find a solution, let us know.

Good luck!
Christoph


To unsubscribe from this group and stop receiving emails from it, send an email to astropy-dev...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages