[398] | 1 | .. _services-debug: |
---|
| 2 | |
---|
| 3 | How To Debug ZOO Services |
---|
| 4 | ========================= |
---|
| 5 | |
---|
| 6 | There are different ways to debug your services, the most used solutions are via web |
---|
| 7 | or via command line. |
---|
| 8 | |
---|
| 9 | Web |
---|
| 10 | ---- |
---|
| 11 | |
---|
| 12 | Using the web request you can see any problem with the log file of Apache. |
---|
| 13 | |
---|
| 14 | On Unix system usually to log file is in ``/var/log/apache2`` and the useful file |
---|
| 15 | is ``error_log``. A simple way to look inside the file is to use ``tail`` command, |
---|
| 16 | it permits to see the update of the file for each request :: |
---|
| 17 | |
---|
| 18 | tail -f /var/log/apache2/error_log |
---|
| 19 | |
---|
| 20 | If the log is not so clear you can add some information inside your code. You have to write |
---|
| 21 | in the standard error. |
---|
| 22 | |
---|
| 23 | Python |
---|
| 24 | ******** |
---|
| 25 | Using Python for example you can do this |
---|
| 26 | |
---|
| 27 | .. code-block:: python |
---|
| 28 | |
---|
| 29 | import sys |
---|
| 30 | |
---|
| 31 | #add this line when you want see your message |
---|
| 32 | sys.stderr.write("My message") |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | Command line |
---|
| 36 | -------------- |
---|
| 37 | |
---|
| 38 | It is possible to use the ZOO kernel ``zoo_loader.cgi`` also from command line. |
---|
| 39 | This is really useful to debug in a deeper way your service. |
---|
| 40 | |
---|
| 41 | .. code-block:: bash |
---|
| 42 | |
---|
| 43 | # to use it you have to copy test_service.py and HelloPy.zcfg from |
---|
| 44 | # the example services |
---|
| 45 | ./zoo_loader.cgi "service=wps&version=1.0.0&request=execute&identifier=HelloPy&datainputs=a=your name&responsedocument=Result" |
---|
| 46 | |
---|
| 47 | Using this way you can use standard debug system of the programming language used |
---|
| 48 | in your service. |
---|
| 49 | |
---|
| 50 | GDB |
---|
| 51 | ***** |
---|
| 52 | From command line you can use also the command line tool `GDB <http://www.gnu.org/software/gdb/>`_ |
---|
| 53 | to debug ``zoo_loader.cgi``, you have to run |
---|
| 54 | |
---|
| 55 | .. code-block:: bash |
---|
| 56 | |
---|
| 57 | # launch zoo_loader.cgi from gdb |
---|
| 58 | gdb zoo_loader.cgi |
---|
| 59 | # now run your request |
---|
| 60 | run "service=wps&version=1.0.0&request=execute&identifier=HelloPy&datainputs=a=your name&responsedocument=Result" |
---|
| 61 | |
---|
| 62 | At this point you can ask help to the `ZOO mailing list <http://lists.osgeo.org/cgi-bin/mailman/listinfo/zoo-discuss>`_ |
---|
| 63 | copying the result of the command. |
---|
| 64 | |
---|
| 65 | Python |
---|
| 66 | ********** |
---|
| 67 | For Python you can use ``pdb``, more info at http://docs.python.org/2/library/pdb.html |
---|
| 68 | |
---|
| 69 | .. code-block:: python |
---|
| 70 | |
---|
| 71 | import pdb |
---|
| 72 | |
---|
| 73 | # add this line when you want investigate more in the code |
---|
| 74 | pdb.set_trace() |
---|