- re.match - If zero or more characters at the beginning of string match the regular expression pattern.
- re.search - Scan through string looking for a location where the regular expression pattern produces a match
Here are the commands I use when I bring up a new Ubuntu server for flask development:
I tried running some select queries on both of the both the virtual container and host for benchmark purposes. My conclusion? MySQL read performance inside and outside the LXC container is the exactly the same.
Site error: the file <b>/var/www/accounts/admin/cron.php</b> requires the ionCube PHP Loader ioncube_loader_lin_5.3.so to be installed by the website operator. If you are the website operator please use the <a href="http://www.ioncube.com/lw/">ionCube Loader Wizard</a> to assist with installation.
You need to add your the ioncube zend extension to the CLI php.ini too: /etc/php5/cli/php.ini
Oct 19 14:04:34 Billing sm-mta: STARTTLS=client, relay=aspmx.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-RC4-SHA, bits=128/128
If you see those errors in your mail.log and your emails are failing to send, you need to add your ssl cert from apache to the sendmail config in /etc/mail/sendmail.cf:
# CA directory
# CA file
# Server Cert
# Server private key
I was getting the following error when I tried testing with openssl:
error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:177
The solution? It turns out that /etc/default/slapd needs to be configured to use /etc/ldap/ldap.conf using the following:
Add the following to /etc/apache2/ports.conf:
Add a file that describes your site to /etc/apache2/sites-available with this:
Run this command: sudo a2ensite misc
And restart apache: sudo service apache2 restart
Simple explanation: http://prakhar.me/articles/flask-on-nginx-and-gunicorn/
Nginx SSL configuration: https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-with-ssl-as-a-reverse-proxy-for-jenkins
The thing I spent the longest on was getting supervisor to work. Gunicorn kept giving me "gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>", because I was missing the "directory" parameter. I needed to tell supervisor which directory to start from.
command=/<path>/venv/prod/bin/gunicorn -w 8 main:app -b 127.0.0.1:8080
You will need to create an upstart script to get supervisor to run when the system starts: http://serverfault.com/a/96500
pyexcelerate : 10.11
xlwt : 15.67
xlsxwriter (optimised): 19.70
xlsxwriter : 23.50
openpyxl (optimised): 95.82
openpyxl : 95.90
It's not really a Flask issue, but the Flask guys were super helpful when I asked why my large dictionary wasn't released from memory: https://github.com/mitsuhiko/flask/issues/1202
I dug even deeper and learned this is a Linux thing:
"Python returns memory to the OS on the heap (that allocates other objects than small objects) only on Windows, if you run on Linux, you can only see the total memory used by your program increase."
Turning it into a function and running it as a separate process: https://gist.github.com/pawl/95769724848269cff890
If you want to go even deeper down the rabbit hole, read these:
- "most malloc implementations will not release memory to the operating system, and the few that do, do not do it very easily" -http://stackoverflow.com/questions/2215259/will-malloc-implementations-return-free-ed-memory-back-to-the-system
- "We compiled a version of Python with TCMalloc that only uses mmap. When testing the new Python in one of our largest projects, we found that not only did Python give back memory to the OS correctly, it also had a reduced memory usage and no apparent CPU penalty for using mmap instead of brk." - http://pushingtheweb.com/2010/06/python-and-tcmalloc/