web2py httpserver log file location

406 views
Skip to first unread message

Yebach

unread,
Jan 11, 2016, 10:06:38 AM1/11/16
to web2py-users
Hello

I have a strange behavior of my log file, or better to say the location of my log file.

If I understand correctly httpserver.log file is usually located in application folder.

When I have to run the engine the following code is executed

        path = applications/applicationName/engine/e1
        count = 0
        while ( count < 10 and ( os.path.isfile(outPath))):
            count += 1 
            os.remove(outPath)
            time.sleep(0.05)
        
        # Run woshi engine
        path_1 =  os.path.join(path, 'e1')
        os.chdir(path_1)
       
        p = subprocess.Popen(['woshi_engine.exe', scriptId], shell=True, stdout = subprocess.PIPE)

After that the httpserver.log file is created in folder applications/applicationName/engine/e1 and stays there

Now if I run my second application in folder applications (like production version) this file is moved to the engine folder of that applicatio

How can I set the default location of httpserver.log file and that the file is not moved?

Thank you 
        

Niphlod

unread,
Jan 11, 2016, 2:50:18 PM1/11/16
to web2py-users
you can't os.chdir in web2py. first it's not threadsafe. second, you screw up all web2py relative imports.

BTW: httpserver.log is put on the same folder web2py.py is, unless you are using the -f parameter, in which case it sits in that directory, which is the one containing the "applications" folder.

Vid Ogris

unread,
Jan 11, 2016, 2:52:58 PM1/11/16
to web...@googlegroups.com

What do u suggest I use to startthe exe program. It takes one parameter (script id)?

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/0WuC-Ahx0W0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Niphlod

unread,
Jan 12, 2016, 6:24:51 AM1/12/16
to web2py-users
for this and the previous issue, you should be on the path "I won't never ever start a process inside a web request".
That being said, subprocess.Popen has cwdir .........

Vid Ogris

unread,
Jan 12, 2016, 8:01:37 AM1/12/16
to web...@googlegroups.com
Using cwdir helped to solve the problem with httpserver.log file. Thank you for that

So you suggest using scheduler to start my exe program?
--
Lep pozdrav 

Vid Ogris


Niphlod

unread,
Jan 12, 2016, 9:14:23 AM1/12/16
to web2py-users
use anything you like EXCEPT something inside the web environment.

Vid Ogris

unread,
Jan 12, 2016, 10:06:31 AM1/12/16
to web...@googlegroups.com
Hello

I tried with sheduller 
In model I created a file called scheduler.py
my code 

def runWoshiEngine(scriptId, path, outPath):
    import os, sys
    import subprocess
    count = 0
    while ( count < 10 and ( os.path.isfile(outPath))):
        count += 1 
        os.remove(outPath)
        time.sleep(0.05)
    
    # Run woshi engine
    path_1 =  os.path.join(path, 'e1')
    p = subprocess.Popen(['woshi_engine.exe', scriptId], shell=True, stdout = subprocess.PIPE, cwd=path_1)
    
  
And in my controller function I did the following

 from gluon.scheduler import Scheduler
 scheduler = Scheduler(db, dict(runFunction = runWoshiEngine(scriptId, path, outPath)))

Is this the right approach? and if it is how can I insert records in my db for scheduler tables?

Thank you

Niphlod

unread,
Jan 12, 2016, 11:24:05 AM1/12/16
to web2py-users
no, it's not. please read the relevant section on the book to get acquainted with the scheduler.

Reply all
Reply to author
Forward
0 new messages