mod_wsgi Exception occurred processing WSGI script '/usr/share/graphite-web/graphite.wsgi'
I copied only apache-graphite.conf to /etc/apache/sites-available, why does it complain about graphite.wsgi?
Content of apache-graphite.conf:
import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'graphite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
from graphite.logger import log
log.info("graphite.wsgi - pid %d - reloading search index" % os.getpid())
import graphite.metrics.search
graphite.wsgi is the wsgi application callled by your apache webserver to answer incoming requests.
The apache-graphite.conf site defines a wsgi application running django which will process requests using graphite code. I guess it looks more like this : https://github.com/graphite-project/graphite-web/blob/0.9.x/examples/example-graphite-vhost.conf
graphite.wsgi usually looks like : https://github.com/graphite-project/graphite-web/blob/0.9.x/conf/graphite.wsgi.example
Related
We are using Mosek's Floating License offering.
That means, the Mosek's license server runs on a separate dedicated server (=xyz and at a port=abc) on-premises. It displays the started the server is started at 127.0.0.1.
Though we (as developer) can use terminal to ssh into that server xyz and check if Mosek license server is up and running.
But for others (non-developer) - its difficult to check Mosek's uptime since they cannot use terminal. (That is the pain-point)
Is it possible to check Mosek's uptime via browser? (possibly by visiting the URL: https://127.0.0.1:abc - this doesn't work for some reason).
(Note: This isn't a necessity but good to have feature for us)
You can use flask:
Create the script flexlm.py
# pip install flask
from flask import Flask, Response
import subprocess
app = Flask(__name__)
#app.route("/status")
def status():
run = subprocess.run(['/opt/flexlm/lmutil', 'lmstat', '-a'], capture_output=True)
return Response(run.stdout, mimetype='text/plain')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080)
Note: you have to customize the parameters of subprocess.run
Run flask application server:
[...]$ python3 flexlm.py
* Serving Flask app 'flexlm' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment.
* Running on http://10.202.120.7:8080/ (Press CTRL+C to quit)
10.202.241.181 - - [01/Mar/2022 14:38:04] "GET / HTTP/1.1" 404 -
10.202.241.181 - - [01/Mar/2022 14:38:08] "GET /status HTTP/1.1" 200 -
Go to http://xyz:5000/status
I am trying to connect to a secure FTP server created based on this link. I have not followed step 8 in the link. I am able to establish the connection and also change and print directories but am unable to create new directories. I am also unable to fetch files list.
Here is my code snippet:
import ssl
from ftplib import FTP_TLS
import sys
import os
import os.path
def connect():
ftp = FTP_TLS()
ftp.debugging = 2
ftp.connect('ipaddress', 21)
ftp.set_pasv(False)
ftp.login('user', 'passwd')
return ftp
ftps = connect()
destdir = "/"
try:
resp = ftps.pwd()
ftps.cwd(destdir)
except Exception:
ftps.mkd(destdir)
print(resp)
root = 'C:\\Users\\****\\****\\Logs' # local dir
for (dir, _, files) in os.walk(root):
newdir = destdir+dir[len(root):len(dir)].replace("\\", "/")
print(newdir)
try:
ftps.cwd(newdir)
except Exception:
ftps.mkd(newdir)
I am using python 3.7.3 and the corresponding ftplib. I would be happy to provide any other details required.
PS: I am able to connect with Filezilla and create directories.
This is the error after running.
I am able to create the directories successfully once I change the dir to /logs. I am getting an error "ftplib.error_perm: 500 Illegal PORT command." whenever I send cmd like retrlines or storbinary
, I get this error
I have searched about this and people have asked to set it to pasv mode. When I do that, I get this error. FYI, I have enabled pasv mode in the config file
I tried changing the port number to a number between pasv ports enabled in the config file (between 30000-31000). It does not connect also in this case. Error returned "ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it"
I am working the first time with an FTP server or for that matter any server communications, so my problems might seem trivial. I am sorry for your trouble.
Thanks.
I have this Flask application running on top of Apache using mod_wsgi.
from flask import Flask
app = Flask(__name__)
#app.route('/<int:a>')
def mytest(a):
print('starting test:', a)
import time
time.sleep(60)
print('ending test:', a)
return 'done'
(This is a MWE.)
When the user accesses the URL /<int>, it performs a low-intensity task for a minute, then returns.
I then open 7 tabs, each in a different URL /1, /2, ..., /7. When I listen to what is going on (sudo tail -f /var/log/apache2/error.log), I see the following messages:
starting test: 1
starting test: 2
starting test: 3
starting test: 4
starting test: 5
starting test: 6
ending test: 1
starting test: 7
...
Clearly, it only supports concurrent requests up to 6. How do I increase this limit?
I am using the default options from the Apache2 that comes with Ubuntu 18.04, and using the default options of mod_wsgi. I have already gone through /etc/apache2/apache2.conf and see no 6 limit. My .wsgi file is configured as:
WSGIDaemonProcess app user=rpcruz group=app home=/var/www/app processes=25 restart-interval=86400 graceful-timeout=3600
I found the issue: The limit was not on the server side. I was testing with Chrome which has a limit of 6 connections per hostname.
I'm trying to run an import script profile on Magento for importing around 1000+ products and I got this error:
mod_fcgid: read data timeout in 31 seconds
End of script output before headers: index.php
Any thoughts?
I am using Apache 2.4.7 with mod_wsgi 3.4 on Ubuntu 14.04.2 (x86_64) and python 3.4.0. My python app relies on apache to perform user authentication against our company’s LDAP server (MS Active Directory 2008). It also passes some additional LDAP data to the python app using the OS environment. In the apache config, I query the LDAP like so:
…
AuthLDAPURL "ldap://server:389/DC=company,DC=lokal?sAMAccountName,sn,givenName,mail,memberOf?sub?(objectClass=*)"
AuthLDAPBindDN …
AuthLDAPBindPassword …
AuthLDAPRemoteUserAttribute sAMAccountName
AuthLDAPAuthorizePrefix AUTHENTICATE_
…
This passes some user data to my WSGI script where I handle the info as follows:
# Make sure the packages from the virtualenv are found
import site
site.addsitedir('/home/user/.virtualenvs/ispot-cons/lib/python3.4/site-packages')
# Patch path for app (so that libispot can be found)
import sys
sys.path.insert(0, '/var/www/my-app/')
import os
from libispot.web import app as _application
def application(environ, start_response):
os.environ['REMOTE_USER'] = environ.get('REMOTE_USER', "")
os.environ['REMOTE_USER_FIRST_NAME'] = environ.get('AUTHENTICATE_GIVENNAME', "")
os.environ['REMOTE_USER_LAST_NAME'] = environ.get('AUTHENTICATE_SN', "")
os.environ['REMOTE_USER_EMAIL'] = environ.get('AUTHENTICATE_MAIL', "")
os.environ['REMOTE_USER_GROUPS'] = environ.get('AUTHENTICATE_MEMBEROF', "")
return _application(environ, start_response)
I can then access this info in my python app using os.environ.get(…). (BTW: If you have a more elegant solution, please let me know!)
The problem is that some of the user names contain special characters (German umlauts, e.g., äöüÄÖÜ) that are not encoded correctly. So, for example, the name Tölle arrives in my python app as Tölle.
Obviously, this is an encoding problem, because
$ echo "Tölle" | iconv --from utf-8 --to latin1
gives me the correct Tölle.
Another observation that might help: in my apache logs I found the character ü represented as \xc3\x83\xc2\xbc.
I told my Apache in /etc/apache2/envvars to use LANG=de_DE.UTF-8 and python 3 is utf-8 aware as well. I can’t seem to specify anything about my LDAP server. So my question is: where is the encoding getting mixed up and how do I mend it?
It is bad practice to copy the values to os.environ on each request as this will fail miserable if the WSGI server is running with a multithreaded configuration, with concurrent requests interfering with each other. Look at thread locals instead.
As to the issue of encoded data from LDAP, if I under stand the problem, you would need to do:
"Tölle".encode('latin-1').decode('utf-8')