Skip to content

Commit 147e7f0

Browse files
committed
docs: split code blocks
1 parent d91b4fe commit 147e7f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1145
-1
lines changed

source/certificates.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ as **GET**-table JSON using **/certificates**:
133133
134134
# curl -X GET --unix-socket :nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` \
135135
http://localhost/certificates/:nxt_hint:`bundle <Certificate bundle name>`/chain/0/
136+
137+
.. code-block:: console
138+
136139
# curl -X GET --unix-socket :nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` \
137140
http://localhost/certificates/:nxt_hint:`bundle <Certificate bundle name>`/chain/0/subject/alt_names/0/
138141

source/configuration/index.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ The **tickets** option works as follows:
421421
422422
LoYjFVxpUFFOj4TzGkr5MsSIRMjhuh8RCsVvtIJiQ12FGhn0nhvvQsEND1+OugQ7
423423
424+
.. code-block:: console
425+
424426
$ openssl rand -base64 80
425427
426428
GQczhdXawyhTrWrtOXI7l3YYUY98PrFYzjGhBbiQsAWgaxm+mbkm4MmZZpDw0tkK
@@ -1971,14 +1973,20 @@ from the incoming requests:
19711973
19721974
HTTP/1.1 201 Created
19731975
1976+
.. code-block:: console
1977+
19741978
$ curl -i -X PUT http://localhost
19751979
19761980
HTTP/1.1 202 Accepted
19771981
1982+
.. code-block:: console
1983+
19781984
$ curl -i -X POST http://localhost
19791985
19801986
HTTP/1.1 203 Non-Authoritative Information
19811987
1988+
.. code-block:: console
1989+
19821990
$ curl -i --head http://localhost # Bumpy ride ahead, no route defined
19831991
19841992
HTTP/1.1 404 Not Found
@@ -2047,6 +2055,9 @@ it is considered empty.
20472055
.. code-block:: console
20482056
20492057
$ curl http://localhost/blog # Targets the 'blog' app
2058+
2059+
.. code-block:: console
2060+
20502061
$ curl http://localhost/sandbox # Targets the 'sandbox' app
20512062
20522063
A different approach puts the **Host** header field
@@ -2777,11 +2788,16 @@ won't be resolved.
27772788
.. code-block:: console
27782789
27792790
$ mkdir -p /www/localhost/static/ && cd /www/localhost/static/
2791+
2792+
.. code-block:: console
2793+
27802794
$ cat > index.html << EOF
27812795
27822796
> index.html
27832797
> EOF
27842798
2799+
.. code-block:: console
2800+
27852801
$ ln -s index.html /www/localhost/static/symlink
27862802
27872803
If symlink resolution is enabled
@@ -2794,6 +2810,8 @@ won't be resolved.
27942810
27952811
index.html
27962812
2813+
.. code-block:: console
2814+
27972815
$ curl http://localhost/symlink
27982816
27992817
index.html
@@ -2819,6 +2837,8 @@ won't be resolved.
28192837
28202838
index.html
28212839
2840+
.. code-block:: console
2841+
28222842
$ curl http://localhost/symlink
28232843
28242844
<!DOCTYPE html><title>Error 403</title><p>Error 403.
@@ -3666,6 +3686,8 @@ and set the **memory.high** limit:
36663686
36673687
cpuset cpu io memory pids
36683688
3689+
.. code-block:: console
3690+
36693691
# echo 1G > /sys/fs/cgroup:nxt_hint:`/staging/app <cgroup's path set in Unit configuration>`/memory.high
36703692
36713693
For more details
@@ -3986,6 +4008,8 @@ and rebuild the app.
39864008
39874009
0
39884010
4011+
.. code-block:: console
4012+
39894013
$ go env -w CGO_ENABLED=1
39904014
39914015
- If you installed Unit from the

source/controlapi.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ OpenAPI specification
181181
.. code-block:: console
182182
183183
$ docker build --tag=unit-openapi -f unit-openapi.Dockerfile .
184+
185+
.. code-block:: console
186+
184187
$ docker run -d -p 8765:8765 -p 8080:8080 unit-openapi
185188
186189
Next, open **http://localhost:8765** in a browser.
@@ -366,6 +369,8 @@ provided you supply the right JSON:
366369
# curl -X PUT -d '{ "pass": "applications/blogs" }' --unix-socket \
367370
:nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` http://localhost/config/listeners/127.0.0.1:8300
368371
372+
.. code-block:: console
373+
369374
# curl -X PUT -d '"applications/blogs"' --unix-socket :nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` \
370375
http://localhost/config/listeners/127.0.0.1:8300/pass
371376
@@ -460,9 +465,13 @@ adding a URI-based route to the development version of the app:
460465
]
461466
EOF
462467
468+
.. code-block:: console
469+
463470
# curl -X PUT --data-binary @config.json --unix-socket \
464471
:nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` http://localhost/config/routes
465472
473+
.. code-block:: console
474+
466475
# curl -X PUT -d '"routes"' --unix-socket \
467476
:nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` 'http://localhost/config/listeners/*:8400/pass'
468477

source/howto/apollo.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,17 @@ using Unit:
2323
.. code-block:: console
2424
2525
$ mkdir -p :nxt_ph:`/path/to/app/ <Path to the application directory; use a real path in your configuration>`
26+
27+
.. code-block:: console
28+
2629
$ cd :nxt_ph:`/path/to/app/ <Path to the application directory; use a real path in your configuration>`
30+
31+
.. code-block:: console
32+
2733
$ npm install @apollo/server graphql
34+
35+
.. code-block:: console
36+
2837
# npm link unit-http
2938
3039
#. Create the `middleware
@@ -35,6 +44,9 @@ using Unit:
3544
.. code-block:: console
3645
3746
$ cd :nxt_ph:`/path/to/app/ <Path to the application directory; use a real path in your configuration>`
47+
48+
.. code-block:: console
49+
3850
$ npm init
3951
4052
Next, add the following code:

source/howto/cakephp.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ To run apps based on the `CakePHP <https://cakephp.org>`_ framework using Unit:
1717
.. code-block:: console
1818
1919
$ cd :nxt_ph:`/path/to/ <Path where the application directory will be created; use a real path in your configuration>`
20+
21+
.. code-block:: console
22+
2023
$ composer create-project --prefer-dist cakephp/app:4.* :nxt_ph:`app <Arbitrary app name; becomes the application directory name>`
2124
2225
This creates the app's directory tree at **/path/to/app/**. Its

source/howto/catalyst.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@ To run apps based on the `Catalyst
2121
.. code-block:: console
2222
2323
$ cd :nxt_ph:`/path/to/ <Path where the application directory will be created; use a real path in your configuration>`
24+
25+
.. code-block:: console
26+
2427
$ catalyst.pl :nxt_ph:`app <Arbitrary app name; becomes the application directory name>`
28+
29+
.. code-block:: console
30+
2531
$ cd app
32+
33+
.. code-block:: console
34+
2635
$ perl Makefile.PL
2736
2837
Make sure the app's **.psgi** file includes the **lib/**

source/howto/certbot.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ Generating Certificates
101101
# cat /etc/letsencrypt/live/www.example.com/fullchain.pem \
102102
/etc/letsencrypt/live/www.example.com/privkey.pem > :nxt_ph:`bundle1.pem <Arbitrary certificate bundle's filename>`
103103
104+
.. code-block:: console
105+
104106
# curl -X PUT --data-binary @:nxt_ph:`bundle1.pem <Certificate bundle's filename>` \
105107
--unix-socket :nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` \
106108
http://localhost/certificates/:nxt_ph:`certbot1 <Certificate bundle name in Unit's configuration>`
@@ -170,9 +172,13 @@ For manual renewal and rollover:
170172
1: Keep the existing certificate for now
171173
2: Renew & replace the cert (may be subject to CA rate limits)
172174
175+
.. code-block:: console
176+
173177
# cat /etc/letsencrypt/live/www.example.com/fullchain.pem \
174178
/etc/letsencrypt/live/www.example.com/privkey.pem > :nxt_ph:`bundle2.pem <Arbitrary certificate bundle's filename>`
175179
180+
.. code-block:: console
181+
176182
# curl -X PUT --data-binary @:nxt_ph:`bundle2.pem <Certificate bundle's filename>` \
177183
--unix-socket :nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` \
178184
http://localhost/certificates/:nxt_ph:`certbot2 <Certificate bundle name in Unit's configuration>`
@@ -229,9 +235,12 @@ For manual renewal and rollover:
229235
# cat /etc/letsencrypt/live/cdn.example.com/fullchain.pem \
230236
/etc/letsencrypt/live/cdn.example.com/privkey.pem > :nxt_hint:`cdn.example.com.pem <Arbitrary certificate bundle's filename>`
231237
238+
.. code-block:: console
239+
232240
# cat /etc/letsencrypt/live/www.example.com/fullchain.pem \
233241
/etc/letsencrypt/live/www.example.com/privkey.pem > :nxt_hint:`www.example.com.pem <Arbitrary certificate bundle's filename>`
234242
243+
.. code-block:: console
235244
236245
# curl -X PUT --data-binary @:nxt_hint:`cdn.example.com.pem <Certificate bundle's filename>` \
237246
--unix-socket :nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` \
@@ -241,6 +250,8 @@ For manual renewal and rollover:
241250
"success": "Certificate chain uploaded."
242251
}
243252
253+
.. code-block:: console
254+
244255
# curl -X PUT --data-binary @:nxt_hint:`www.example.com.pem <Certificate bundle's filename>` \
245256
--unix-socket :nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` \
246257
http://localhost/certificates/:nxt_hint:`www.example.com <Certificate bundle name in Unit's configuration>`

source/howto/djangochannels.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@ To run Django apps using the |app| `framework
2121
.. code-block:: console
2222
2323
$ cd :nxt_ph:`/path/to/venv/ <Path to the virtual environment; use a real path in your configuration>`
24+
25+
.. code-block:: console
26+
2427
$ source bin/activate
28+
29+
.. code-block:: console
30+
2531
$ pip install channels
32+
33+
.. code-block:: console
34+
2635
$ deactivate
2736
2837
#. Create a Django project. Here, we'll use the `tutorial chat app

source/howto/docker.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ official **hello, world** app:
6464
.. code-block:: console
6565
6666
$ cd :nxt_ph:`/path/to/app/ <Directory where all app-related files will be stored; use a real path in your configuration>`
67+
68+
.. code-block:: console
69+
6770
$ mkdir webapp
71+
72+
.. code-block:: console
73+
6874
$ cat << EOF > webapp/wsgi.py
6975
7076
from flask import Flask
@@ -91,6 +97,9 @@ app:
9197
.. code-block:: console
9298
9399
$ mkdir config
100+
101+
.. code-block:: console
102+
94103
$ cat << EOF > config/config.json
95104
96105
{
@@ -117,7 +126,13 @@ Finally, let's create **log/** and **state/** directories to store Unit
117126
.. code-block:: console
118127
119128
$ mkdir log
129+
130+
.. code-block:: console
131+
120132
$ touch log/unit.log
133+
134+
.. code-block:: console
135+
121136
$ mkdir state
122137
123138
Our file structure so far:
@@ -315,12 +330,16 @@ Unit's state:
315330
316331
$ docker build --tag=:nxt_hint:`unit-expressapp <Arbitrary image tag>` .
317332
333+
.. code-block:: console
334+
318335
$ export UNIT=$( \
319336
docker run -d \
320337
--mount type=bind,src="$(pwd)/myapp/config.json",dst=/docker-entrypoint.d/config.json \
321338
-p 8080:8080 unit-expressapp \
322339
)
323340
341+
.. code-block:: console
342+
324343
$ curl -X GET localhost:8080
325344
326345
Hello, Unit!
@@ -358,16 +377,22 @@ the :ref:`control API <configuration-api>`:
358377
...
359378
EOF
360379
380+
.. code-block:: console
381+
361382
$ export UNIT=$( \
362383
docker run -d \
363384
--mount type=bind,src="$(pwd)/myapp/new-config.json",dst=/cfg/new-config.json \
364385
unit-expressapp \
365386
)
366387
388+
.. code-block:: console
389+
367390
$ docker exec -ti $UNIT curl -X PUT --data-binary @/cfg/new-config.json \
368391
--unix-socket /var/run/control.unit.sock \
369392
http://localhost/config
370393
394+
.. code-block:: console
395+
371396
$ docker exec -ti $UNIT curl -X PUT -d '"/www/newapp/"' \
372397
--unix-socket /var/run/control.unit.sock \
373398
http://localhost/config/applications/express/working_directory

source/howto/dokuwiki.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@ using Unit:
2121
.. code-block:: console
2222
2323
$ mkdir -p :nxt_ph:`/path/to/app/ <Path to the application directory; use a real path in your configuration>` && cd :nxt_ph:`/path/to/app/ <Path to the application directory; use a real path in your configuration>`
24+
25+
.. code-block:: console
26+
2427
$ wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
28+
29+
.. code-block:: console
30+
2531
$ tar xvzf dokuwiki-stable.tgz :nxt_hint:`--strip-components <Avoids creating a redundant subdirectory>`=1
32+
33+
.. code-block:: console
34+
2635
$ rm dokuwiki-stable.tgz
2736
2837
#. .. include:: ../include/howto_change_ownership.rst

source/howto/express.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,17 @@ using Unit:
2323
.. code-block:: console
2424
2525
$ mkdir -p :nxt_ph:`/path/to/app/ <Path to the application directory; use a real path in your configuration>`
26+
27+
.. code-block:: console
28+
2629
$ cd :nxt_ph:`/path/to/app/ <Path to the application directory; use a real path in your configuration>`
30+
31+
.. code-block:: console
32+
2733
$ npm install express --save
34+
35+
.. code-block:: console
36+
2837
# npm link unit-http
2938
3039
#. Create your Express `app
@@ -34,6 +43,9 @@ using Unit:
3443
.. code-block:: console
3544
3645
$ cd :nxt_ph:`/path/to/app/ <Path to the application directory; use a real path in your configuration>`
46+
47+
.. code-block:: console
48+
3749
$ npm init
3850
3951
Next, add your application code:

0 commit comments

Comments
 (0)