Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loris not creating tmp file #446

Open
ericvanderlinden opened this issue Mar 2, 2019 · 15 comments
Open

Loris not creating tmp file #446

ericvanderlinden opened this issue Mar 2, 2019 · 15 comments
Labels

Comments

@ericvanderlinden
Copy link

ericvanderlinden commented Mar 2, 2019

I have installed Loris according to the documentation. Everything seems to be fine exept I get a
Internal Server Error (500) because a temp should be created and it is not created.
I'm on Ubuntu 18.

I have searched via google for reports of similar errors but nothing.

Any ideas?

mod_wsgi (pid=23297): Exception occurred processing WSGI script '/var/www/html/loris2/loris2.wsgi'.
 Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.3-py2.7.egg/loris/webapp.py", line 453, in __call__

     return self.wsgi_app(environ, start_response)
     
File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.3-py2.7.egg/loris/webapp.py", line 396, in wsgi_app
     response = self.route(request)
File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.3-py2.7.egg/loris/webapp.py", line 447, in route
     return self.get_img(request, ident, region, size, rotation, quality, fmt, base_uri)
File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.3-py2.7.egg/loris/webapp.py", line 668, in get_img
     image_info=info
File "/usr/local/lib/python2.7/dist-packages/Loris-2.3.3-py2.7.egg/loris/webapp.py", line 722, in _make_image
     delete=False
File "/usr/lib/python2.7/tempfile.py", line 485, in NamedTemporaryFile
     (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
File "/usr/lib/python2.7/tempfile.py", line 254, in _mkstemp_inner`
     fd = _os.open(file, flags, 0600)
 
OSError: [Errno 2] No such file or directory: '/tmp/loris2/tmp/tmp1G9IJi.jpg'
@alexwlchan
Copy link
Contributor

alexwlchan commented Mar 3, 2019

This looks like a straight-up bug – we assign a temporary directory from the loris.Loris.tmp_dp config setting, but never do anything to check the directory exists or that we can write to it!

You should be able to fix this by running mkdir -p /tmp/loris2/tmp on the system that’s running Loris. I’ll have a look at writing a patch so that Loris handles this automatically.

@ericvanderlinden
Copy link
Author

It is always a good ideas to do the checking, but in this case the tmp directory in /tmp/loris2 did exist.

@alexwlchan
Copy link
Contributor

Okay, that’s weird. There might be a problem if Loris didn’t have permissions, say, but then I’d expect to see a different error coming out.

@ericvanderlinden
Copy link
Author

Wel I put the permissions on 777 just to make sure... but I still get the same error.

@bcail bcail closed this as completed in #447 Mar 6, 2019
@ericvanderlinden
Copy link
Author

You closed this with a solution to a problem I did not have.
So I think I must conclude from this you have no ideas...

@alexwlchan alexwlchan reopened this Mar 7, 2019
@alexwlchan
Copy link
Contributor

It got closed automatically by GitHub. I take it you’re still seeing this error?

@ericvanderlinden
Copy link
Author

Yes. I was about to rewrite the function in webapp.py to create a temp file bypassing the python module. To see if the problem is python NamedTemporaryFile.

@ericvanderlinden
Copy link
Author

Does Loris keep versions of webapp.py somewhere in a cache? I have tried to change some line of code to see what would happen. And now it seems like I get a different response every time I reload.

To be honest... I think I'm going to give up... Maybe there is some problem with Ubuntu 18.04...
and temp files....

I deleted temp_file = NamedTemporaryFile( ...
And created a new binairy file with open() to see if a file is created... But no file created.

Now I get the same error as befor... but also:
Server Side Error: [Errno 2] No such file or directory: '/tmp/loris2/tmpfile2.jpg'

This is likely a permissions problem, though it's
possible that there was a problem with the source file
(/usr/local/share/images/01/03/0001.jpg). (500)

Server Side Error: [Errno 2] No such file or directory: '/tmp/loris2/tmp/tmp/file2.jpg'

This is likely a permissions problem, though it's
possible that there was a problem with the source file
(/usr/local/share/images/01/03/0001.jpg). (500)

@bcail
Copy link
Contributor

bcail commented Mar 7, 2019

@ericvanderlinden could you try using a different tmp directory? Maybe try setting the tmp directory to be in your home directory, and see if anything changes. Is /tmp a normal directory on /, or is it mounted somehow?

@ericvanderlinden
Copy link
Author

I changed the temp directory to 

/home/loris/tmp

What happened was that as I kept reloading the image Loris seemed to hope from one version of the loris.config and webapp.py to the other, but did not use the latest version.

The reason I was puzzled by this behavior is that I have never experienced this before and I have been using a Leaseweb virtual server for the last 4 yours.

This morning I restarted the server and now it works.

Maybe /home/loris is a better initial setting.

For your information:

server: https://www.leaseweb.com/nl/cloud/public/virtual-server

installed 2/2019 with Ubuntu 18.04 and the most recent versions of all software like Apache etc.

@bcail
Copy link
Contributor

bcail commented Mar 8, 2019

@ericvanderlinden does "mount | grep /tmp" return anything on the machine?

@ericvanderlinden
Copy link
Author

Sorry I have been away.
Mount | grep /tmp
returns nothing.

@bcail
Copy link
Contributor

bcail commented Mar 15, 2019

@ericvanderlinden can you confirm that you can create a file in /tmp as the loris user? If it works using "touch /tmp/test", maybe you could try with a tiny python script like this:

import tempfile
with tempfile.NamedTemporaryFile(dir='/tmp', delete=False) as f:
    print(f.name)
    f.write('test')

Does it create the file there?

@ericvanderlinden
Copy link
Author

I logged in as loris.
cd /tml
I started nano and created a file test.txt
This was successful.
Then I create a directory
mkdir loristest
This was successful as well

I hope this answers your question

@bcail
Copy link
Contributor

bcail commented Mar 25, 2019

ok, that shows that the Loris user can create files/directories in /tmp. You could try the little python script if you want. I'm not sure why the Loris code can't create files, when the loris user can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants