Mercurial > hg > orthanc-book
comparison Sphinx/source/users/lua.rst @ 355:e4e9cca89c64 David-Wikler/clarified-mutual-exclusion-of-callback-1585511553371
clarified mutual exclusion of Lua scripts callbacks.
author | David Wikler <david.wikler@ulb.ac.be> |
---|---|
date | Sun, 29 Mar 2020 19:54:02 +0000 |
parents | be69f8c86f56 |
children | 6b432ce3a56e |
comparison
equal
deleted
inserted
replaced
354:1ba75bac55fd | 355:e4e9cca89c64 |
---|---|
25 file <configuration>`, or by uploading it | 25 file <configuration>`, or by uploading it |
26 through the :ref:`REST API <rest-samples>`. | 26 through the :ref:`REST API <rest-samples>`. |
27 | 27 |
28 To install it by the **configuration file** method, you just have to | 28 To install it by the **configuration file** method, you just have to |
29 specify the path to the file containing the Lua script in the | 29 specify the path to the file containing the Lua script in the |
30 ``LuaScripts`` variable. | 30 ``LuaScripts`` variable. A comma seprated list of paths can be specified |
31 to install multiple scripts. | |
31 | 32 |
32 To upload a script stored in the file "``script.lua``" through the | 33 To upload a script stored in the file "``script.lua``" through the |
33 **REST API**, use the following command:: | 34 **REST API**, use the following command:: |
34 | 35 |
35 $ curl -X POST http://localhost:8042/tools/execute-script --data-binary @script.lua | 36 $ curl -X POST http://localhost:8042/tools/execute-script --data-binary @script.lua |
46 ``--data`` to prevent the interpretation of newlines by cURL, which is | 47 ``--data`` to prevent the interpretation of newlines by cURL, which is |
47 `mandatory for the proper evaluation | 48 `mandatory for the proper evaluation |
48 <http://stackoverflow.com/questions/3872427/how-to-send-line-break-with-curl>`__ of the possible | 49 <http://stackoverflow.com/questions/3872427/how-to-send-line-break-with-curl>`__ of the possible |
49 comments inside the Lua script. | 50 comments inside the Lua script. |
50 | 51 |
51 | |
52 Lua API | 52 Lua API |
53 ------- | 53 ------- |
54 | 54 |
55 | 55 |
56 .. _lua-callbacks: | 56 .. _lua-callbacks: |
57 | 57 |
58 Callbacks to react to events | 58 Callbacks to react to events |
59 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 59 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
60 | 60 |
61 The Lua engine of Orthanc comes invokes the following callbacks that | 61 The Lua engine of Orthanc invokes the following callbacks that |
62 are triggered on various events. Here are the **generic events**: | 62 are triggered on various events. Here are the **generic events**: |
63 | 63 |
64 * ``function Initialize()``: Invoked as soon as the Orthanc server is started. | 64 * ``function Initialize()``: Invoked as soon as the Orthanc server is started. |
65 * ``function Finalize()``: Invoked just before the Orthanc server is stopped. | 65 * ``function Finalize()``: Invoked just before the Orthanc server is stopped. |
66 | 66 |
139 callbacks are listed in `this sample script | 139 callbacks are listed in `this sample script |
140 <https://bitbucket.org/sjodogne/orthanc/src/default/Resources/Samples/Lua/TransferSyntaxEnable.lua>`__. | 140 <https://bitbucket.org/sjodogne/orthanc/src/default/Resources/Samples/Lua/TransferSyntaxEnable.lua>`__. |
141 | 141 |
142 *Note:* All of these callbacks are guaranteed to be **invoked in | 142 *Note:* All of these callbacks are guaranteed to be **invoked in |
143 mutual exclusion**. This implies that Lua scripting in Orthanc does | 143 mutual exclusion**. This implies that Lua scripting in Orthanc does |
144 not support any kind of concurrency. | 144 not support any kind of concurrency. If a callback is specified |
145 multiple times in separate scripts, the event handler of the latest | |
146 loaded script is used. | |
145 | 147 |
146 | 148 |
147 .. _lua-rest: | 149 .. _lua-rest: |
148 | 150 |
149 Calling the REST API of Orthanc | 151 Calling the REST API of Orthanc |