@@ -81,22 +81,25 @@ Remote server configuration
81
81
82
82
The remote server accepts following configuration parameters:
83
83
84
- ============== ================ ========================================
85
- Argument Default Explanation
86
- ============== ================ ========================================
87
- ``library `` Test library instance or module to host. Mandatory argument.
88
- ``host `` ``'127.0.0.1' `` Address to listen. Use ``'0.0.0.0' `` to listen to all available interfaces.
89
- ``port `` ``8270 `` Port to listen. Use ``0 `` to select a free port automatically. Can be given as an integer or as a string.
90
- ``port_file `` ``None `` File to write port that is used. ``None `` means no such file is written.
91
- ``allow_stop `` ``True `` Allow/disallow stopping the server using ``Stop Remote Server `` keyword.
92
- ============== ================ ========================================
84
+ ===================== ================= ========================================
85
+ Argument Default Explanation
86
+ ===================== ================= ========================================
87
+ ``library `` Test library instance or module to host. Mandatory argument.
88
+ ``host `` ``'127.0.0.1' `` Address to listen. Use ``'0.0.0.0' `` to listen to all available interfaces.
89
+ ``port `` ``8270 `` Port to listen. Use ``0 `` to select a free port automatically. Can be given as an integer or as a string.
90
+ ``port_file `` ``None `` File to write port that is used. ``None `` means no such file is written.
91
+ ``allow_stop `` ``'DEPRECATED' `` DEPRECATED. User ``allow_remote_stop `` instead.
92
+ ``serve `` ``True `` If ``True ``, start the server automatically and wait for it to be stopped. If ``False ``, server can be started using ``serve `` or ``start `` methods. New in version 1.1.
93
+ ``allow_remote_stop `` ``True `` Allow/disallow stopping the server using ``Stop Remote Server `` keyword and ``stop_remote_server `` XML-RPC method. New in version 1.1.
94
+ ===================== ================= ========================================
93
95
94
96
Address and port that are used are printed to the console where the server is
95
97
started. Writing port to a file by using ``port_file `` argument is especially
96
98
useful when the server selects a free port automatically. Other tools can then
97
99
easily read the active port from the file. If the file is removed prior to
98
100
starting the server, tools can also wait until the file exists to know that
99
- the server is up and running.
101
+ the server is up and running. Starting from version 1.1, the server removes
102
+ the port file automatically.
100
103
101
104
Example:
102
105
@@ -106,23 +109,23 @@ Example:
106
109
from mylibrary import MyLibrary
107
110
108
111
RobotRemoteServer(MyLibrary(), host='10.0.0.42', port=0,
109
- port_file='/tmp/remote-port.txt', allow_stop=False )
112
+ port_file='/tmp/remote-port.txt')
110
113
111
- Testing is server running
112
- -------------------------
114
+ Starting from versoin 1.1, the server can also first be initialized and started
115
+ afterwards:
113
116
114
- Starting from version 1.0.1 , ``robotremoteserver `` module supports testing is
115
- a remote server running. This can be accomplished by running the module as
116
- a script with ``test `` argument and an optional URI::
117
+ .. sourcecode :: python
117
118
118
- $ python -m robotremoteserver test
119
- Remote server running at http://127.0.0.1:8270.
120
- $ python -m robotremoteserver test http://10.0.0.42:57347
121
- No remote server running at http://10.0.0.42:57347.
119
+ server = RobotRemoteServer(MyLibrary(), host='10.0.0.42', port=0,
120
+ port_file='/tmp/remote-port.txt', serve=False)
121
+ server.serve()
122
+
123
+ The above is totally equivalent to the earlier example and both of them result
124
+ with the server starting and running until it is `explicitly stopped `__.
125
+ Alternatively it is possible to `start the server on background `__.
122
126
123
- .. tip :: As discussed below, using ``stop`` instead of ``test`` allows stopping
124
- the server. Both testing and stopping should work also against other
125
- Robot Framework remote server implementations.
127
+ __ `Stopping remote server `_
128
+ __ `Starting server on background `_
126
129
127
130
Stopping remote server
128
131
----------------------
@@ -136,19 +139,77 @@ The remote server can be gracefully stopped using several different methods:
136
139
work on Windows. Notice that with Jython you need to send the signal to the
137
140
started Java process, not to the shell typically started by ``jython `` command.
138
141
139
- - Using ``Stop Remote Server `` keyword. This can be disabled by using
140
- ``allow_stop=False `` when starting the server.
142
+ - Using ``Stop Remote Server `` keyword.
143
+
144
+ - Using ``stop_remote_server `` function in the XML-RPC interface.
145
+
146
+ - Running ``python -m robotremoteserver stop [uri] `` or using
147
+ ``stop_remote_server `` function similarly as when `testing is server running `_.
148
+
149
+ - Calling ``stop `` method of the running server object.
150
+
151
+ Using ``Stop Remote Server `` keyword, ``stop_remote_server `` XML-RPC function
152
+ or stopping functionality provided by ``robotremoteserver `` itself can all be
153
+ disabled by using ``allow_remote_stop=False `` when initializing the server.
154
+
155
+ Starting server on background
156
+ -----------------------------
157
+
158
+ Sometimes it is useful to start the server on background and keep doing
159
+ something else, like starting more servers, on the main thread. Starting
160
+ from RobotRemoteServer 1.1 this can be accomplished easily:
161
+
162
+ .. sourcecode :: python
163
+
164
+ from robotremoteserver import RobotRemoteServer
165
+ from mylibrary import MyLibrary
166
+
167
+ server = RobotRemoteServer(MyLibrary(), port=0, serve=False)
168
+ server.start()
169
+ print('Remote server started on port %d.' % server.server_port)
170
+ # Do something ...
171
+ server.stop()
172
+
173
+ As the above example illustrates, the ``start `` method starts the server on
174
+ background. When the server is started on background, none of the earlier
175
+ methods to `stop the server `__ work. Instead the server can be stopped, as
176
+ shown in the example, by using the ``stop `` method.
177
+
178
+ __ `Stopping remote server `_
179
+
180
+ Testing is server running
181
+ -------------------------
182
+
183
+ Starting from version 1.0.1 , ``robotremoteserver `` module supports testing is
184
+ a remote server running. This can be accomplished by running the module as
185
+ a script with ``test `` argument and an optional URI::
186
+
187
+ $ python -m robotremoteserver test
188
+ Remote server running at http://127.0.0.1:8270.
189
+ $ python -m robotremoteserver test http://10.0.0.42:57347
190
+ No remote server running at http://10.0.0.42:57347.
191
+
192
+ Starting from version 1.1, ``robotremoteserver `` module contains function
193
+ ``stop_remote_server `` that can be used programmatically:
194
+
195
+ .. sourcecode :: python
196
+
197
+ from robotremoteserver import test_remote_server
198
+
199
+ if test_remote_server('http://localhost:8270'):
200
+ print('Remote server running!')
141
201
142
- - Running ``python -m robotremoteserver stop [uri] `` similarly as when `testing
143
- is server running `_. Also this can be disabled using ``allow_stop=False ``.
144
- New in version 1.0.1.
202
+ ``robotremoteserver `` can be also used to stop a remote server by using
203
+ ``stop `` argument on the command line or by using ``stop_remote_server ``
204
+ function programmatically. Testing and stopping should work also with
205
+ other Robot Framework remote server implementations.
145
206
146
207
Example
147
208
-------
148
209
149
- The remote server project contains an example _ that can be studied and also
210
+ The remote server project contains an example __ that can be studied and also
150
211
executed once the library is installed. You can get the example by cloning
151
212
the project on GitHub _, and it is also included in the source distribution
152
213
available on PyPI _.
153
214
154
- .. _ example : https://github.com/robotframework/PythonRemoteServer/tree/master/example
215
+ __ https://github.com/robotframework/PythonRemoteServer/tree/master/example
0 commit comments