OpenERP Remote debugging on server
We are going to use:
X11 Forwarding
Intro to X Forwarding
Unix machines have been able to run software on a remote machine and display the GUI locally for almost two decades. Linux and Mac OS X support X Forwarding with no extra software. Any terminal on Linux should do X Forwarding, Mac users need to run "Applications > Utilities > XTerm". In a command line terminal run "ssh -Y jdoe@compute.example.edu matlab" and you'll be running matlab on "compute.example.edu" but seeing it on your desktop.
Windows users need two pieces of software: an secure shell program (ssh) to establish the remote connection and an X Server to handle the local display.
On server side make sure that X11 Forwarding is enabled.
Config File
SSH looks for the user config file in ~/.ssh/config. A sample might look like:
ForwardX11 yes
Protocol 2,1
Linux Client
Using ssh Compression
-C, and changing encryption to blowfish -c blowfishis giving a speed boost, when you debug over slow connections, but is not mandatory. We enable X11Forwarding with option -Xssh -X -C -c blowfish username@serverIn this way, when you execute a command that needs to open a window in the remote computer, the window will open on your desktop.
Windows Client
You need an X Server, and a ssh client.
I use Xming, and putty.
After you install Xming, configure putty to use X 11 Forwarding.
Configuring Putty
1. Add Unix hostname
2. Switch Protocol to SSH
3. Type name of session in saved sessions
4. Click 'Save'
5. Choose 'Tunnels' from 'Category' list
6. Check 'Enable X11 Forwarding'
6.1. Type"localhost:0" in X Display location
7. Choose 'Session' from 'Category' list
8. Click 'Save'
Starting the X Server on Windows
Configuring Xming
Just run "All Programs > Xming Xming" and it should work if you've got PuTTY configured.
Connecting
1. Start Xming
2. Start Putty
3. Double click on the saved session you want
4. Enter username and password as requested (you can also configure public keys to speed-up)
5. You should now be able to run X applications from the host
on your local desktop
It is also possible to use other X Clients like XWin32.
check also this page for references
Linux Server
In this case we use a Linux headless server.
Ubuntu 10.04 LTS
Eclipse with PyDev
Linux server side
We need java installed for running Eclipse
sudo apt-get install openjdk-6-jdk
Install Eclipse on Ubuntu (Galileo in my case)
sudo apt-get install eclipse
Client side
Eclipse will open on the client screen but actually will operate entirely on the OpenERP server.
Now, eclipse needs to be configured.
Select menu Help:->install new software
Choose Add
name: "Pydev"
location: "http://pydev.org/updates"
no quotes
Press "ok"
then in the next list check "Pydev" just "Pydev" not the other options.
then "finish"
Now we configure the environment for debug
Open window->Preferences
and choose from left side
"Pydev"
ant there "Interpreter - Python"
press "new" in the right side
choose "browse" and browse for /usr/bin/python
select "ok"
click "select all" to import all paths and click "OK"
Ready to work!
Now testing:
Select Window->Show View->Console
-press New -Project->Pydev ..
choose grammatic -> 2.5
type "helloworld" for project name
right click on the newly created project and "new - > file" type "helloworld.py"
in this file:
import sys
def testing():
print "Hello world"
print sys.version
testing()
from menu select "run-> python run"
in console should say "hello world" and python version
Now debug openerp
stop openerp server
from treminal in server write:
sudo invoke-rc.d openerp-serer stop
then in eclipse create a new project :
new-project->pydev python
un-check default path and browse to openerp-server path:
(in my case) .
/usr/lib/openerp-sever/
leave checked "create folder src ..."
now he project will be created
expand the project and right click on "openerp-server.py"
chose "Run - > Python run"
if all is ok you will have in console after many messages:
INFO:server:OpenERP server is running, waiting for connections...
Now a full featured debug environment is available for you.
Troubleshooting:
If the openerp database owner is not the owner taht runs the eclipse IDE in the server, there will be connection problems when accessing the database from the client, also if you "su" then the X11 Forwarding will not work correctly.
to overcome this I did the following:
solution for X11 Forwarding after "su"
ssh ip -X -C -c blowfish remote_user@server
echo $DISPLAY
ex: localhost:10.0
copy the output in memory
sudo -i
cat /home/remote_user/.Xauthority > /home/user_owner_openerp/.Xauthority
export DISPLAY="paste the output of echo $DISPLAY here... without quotes"
su user_owner_openerp
eclpse &
PS
Please forgive the messy style, mind that this is mainly a quick reference for myself.
0 comentarii:
Trimiteţi un comentariu