Wagtail Admin Images Crash - django

Since I updated my production setup to Wagtail 1.11 I cannot load the admin page for images. Visiting /admin/images/ results in a 502 error. In my development setup I don't have the same problem
This is the result of a crash of the runner. The memory and CPU usage of the runners gets too high for the server to handle at which point they are killed. (Seen in top and restarts are shown in the logs)
This seems to be the same as https://github.com/wagtail/wagtail/issues/3575, but Wand is not used and no GIF images are uploaded to the system so this is not the cause. The following seemingly relevant python packages are used:
Django==1.11.3
gunicorn==19.7.1
Pillow==4.2.1
wagtail==1.11.1
Willow==0.4
The project is running on a fully updated Ubuntu 16.04 machine.
Does anyone have a suggestion of what can fix this bug?

Try removing some of the more recent or larger images and reloading the page. The problem could be the result of a corrupt or malicious image.
The easiest way to diagnose if this is the problem is to:
Move all images from the media/original_images folder to a backup folder.
Access the /admin/images page. If this was the problem the page should now load again.
Note all images that now do not have a thumbnail; these are the pictures crashing the application.
Move all picture except for the ones noted back into the media/original_images folder.
Except for the picture crashing your system, everything should now work similar to what it did before.

Related

Dango bootstrap styling shows up fine on dev-box, not on production

I've got a Django site which uses the "django-machina" forum software, which in its latest incarnation apparently uses Bootstrap4 styling.
After installing the package according to directions, it looks beautiful on my development box. But, when I deploy exactly the same software on production, Bootstrap obviously isn't running because nothing is properly styled.
There are no 404's and no console messages. *(Yes, I remembered to run manage.py collectstatic ...) There are some stylesheets complaints from Firefox but they're identical in both cases. But ... the display is not!
Can anyone suggest what I might do in order to solve this problem? I'm stumped!
Well, once again I answered my own question!
I correctly guessed that, since I was maintaining the remote site from my own box using rsync, there might be some garbage left over on the remote side that wasn't being swept-up. (I can't use rsync --delete for fear of smashing directories that contain images and uploaded materials.) I guess it would probably be smarter for me to start using an external repo so that git can do for me what it's designed to do ...
But anyway, when I deleted selected directories containing the central and most-often updated directories, then used rsync to replace them with clean copies, the interference went away and production now looks correct.

vQmod fails to write to vqcache directory on OpenCart

Can anyone suggest why vQmod fails to write cache files and instead writes an empty file named vq2-C to /vqmod/vqcache?
Environment
Windows Server 2012
Plesk Panel 12.5
PHP 5.3.2.9
MySQL 5.6.26
OpenCart 2.1.0.1
vQmod 2.6.1
Issue
vQmod fails to save modifications to /vqmod/vqcache/vq2-*.php
On each page load it applies modifications specified in /vqmod/xml/*.xml and writes an empty file named vq2-C to /vqmod/vqcache.
Background
The affected website was migrated from another Windows box with similar configuration.
In short the old server ran Plesk Panel 12.0, the new server is Plesk 12.5 so has minor updates to software versions.
Both sites run on PHP 5.3.2.9 and the new server follows OWASP recommendations more closely so has more PHP functions disabled eg. fopen_with_path.
Investigation so far
Running the vQmod installer again reports: VQMOD ALREADY INSTALLED!
File permissions
/vqmod/logs and /vqmod/vqcache have modify permissions, files are written here. Permissions are applied through Plesk Panel, checked over remote desktop and enabling global write permissions on web root through Plesk does not change anything.
Logs
vQmod logs have no useful information, only skipped files are noted eg. VQModObject::parseMods - Could not resolve path for [ catalog/language/english/module/featured.php] (SKIPPED).
No php_error.log files are generated.
Failed Request Tracing does not pick up any issues.
Tests
All /vqmod/xml files have been removed except vqmod_opencart.xml and one that modifies column_left.tpl. These modifications are applied successfully but no cache files are generated in /vqmod/vqcache.
If I remove /vqmod/checked.cache and /vqmod/mods.cache the files are regenerated on next page load.
vQmod versions - rolled back to 2.5.1 but the issue persists.
Other considerations
When one particular vQmod modification is enabled page load time is unacceptably slow (up to 20 sec). The modification displays the first 4 products from sub categories on the parent category page. I've not gone through the code yet but assume it's hitting pretty hard on the database.
On the original server page load was sub 2 seconds. I doubt this is related to the cache issue as that seems to be a permissions problem.
I had such an issue with mine, I later found out that the issue was with directory permissions, in this case, might be caused by moving. Set permissions of vqcache folder recursively to 777. It worked for me.
My apologies, I should have updated this sooner.
The issue relates to case sensitive preg_replace.
In short changing line #120 of vqmod.php from
$stripped_filename = preg_replace('~^' . preg_quote(self::getCwd(), '~i') . '~', '', $sourcePath)
to
$stripped_filename = preg_replace('~^' . preg_quote(self::getCwd(), '~i') . '~i', '', $sourcePath);
Means the /vqmod/vqcache/vq2-*.php cache files are written and the website runs as normal.
Explained in more detail at https://github.com/vqmod/vqmod/issues/81
I don't think the preg_quote should have the i argumment but it's in the original code so I left it in.

Opencart 1.5 (ocStore): after coping to another hosting I see an infinite load of main page

This is not first time when I see this infinite loading after copying my OpenCart shop - but if I look to source of page in browser - I see the code and loaded resources at Network tab at Chrome. After maybe 10 minutes of loading sometimes I can see my site that looks like without CSS.
My steps: creating new VM at Google Cloud, installation of mysql (+ creation user & "grant all"), installation of apache2, phpmyadmin, copy files from old hosting and at config.php change internal path.
At /var/log/apache2/error.log no one error. Apache and MySQL is working. VM is fast enough and CPU with RAM not loaded too much. Restart of VM does not help.
Where can be the problem?
Often, this is caused by a typo in the config file for the HTTP_SERVER. Make sure it's formatted as http://www.domain.co.uk/ , anything else could cause the loop.

Django pages loading very slowly in EC2

I'm at a loss here.
I am attempting to transfer a Django application to EC2. I ave moved the DB to RDS(Postgres image) and have static and media on S3.
However for some reason, all my pages are taking 25-30 seconds to load. I have checked the images and CPU and memory barely blips. I checked and took off KeepAlive in Apache, and changed the WSGI to work in daemon mode, but none of this made any difference. I have gone into the shell on the machine and accessed the DB and that appears to be reacting fine as well. I ahve also increased the EC2 image, with no effect.
S3 items are also being delivered quickly and without issue. Only the rendering of the html is taking long times.
On our current live and test server, there are no issues with the pages which load in ms
Can anyone point me to where or what I should be looking at?
Marc
The issue appeared to be connected with using RDS. I installed Postgres on the EC2 image and appart from a little mucking around it worked fine on there.
I'm going to try building a new RDS, but that was the issue here. Strange it worked ok directly via manage.py shell

Images disappear in Django app when deployed to Heroku

l have deployed my app to Heroku but some images are no longer being loaded.
For example, people's profile pics are not showing up, but if that person re-uploads one it will be visible. However, when they log out/in again, the picture is no longer there.
What would cause this type of behavior and how can I fix it? Locally everything works fine.
I found this information on http://www.gettingstartedwithdjango.com/introduction-and-launch.html#what-heroku-does-every-time-you-push-to-them-is
What Heroku does every time you push to them is:
Creates a new app space with its own virtual machine, virtual environment, and packages installed through pip.
Swaps the subdomain over to the new location.
Deletes the old app space.
What this means is that anything added to the app that is not in Git, won’t last between pushes. Even more, this exact same process happens once every 24 hours anyway, so uploaded files have to go somewhere other than Heroku.
You might look into this as a possible source of your issue.
Here is an answer from the pythonanywhere blog which may answer your question.
Basically, when going into production, setting (in settings.py) DEBUG = False raises a security lock on the file tampering with the image urls.
So basically a file path change is in order for the MEDIA_ROOT from development to production.
More information given on the blog here.
Hope this helps!