Skip to content

Commit

Permalink
docs: split code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jcahilltorre committed Sep 12, 2024
1 parent d91b4fe commit 147e7f0
Show file tree
Hide file tree
Showing 41 changed files with 1,145 additions and 1 deletion.
3 changes: 3 additions & 0 deletions source/certificates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ as **GET**-table JSON using **/certificates**:
# curl -X GET --unix-socket :nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` \
http://localhost/certificates/:nxt_hint:`bundle <Certificate bundle name>`/chain/0/
.. code-block:: console
# curl -X GET --unix-socket :nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` \
http://localhost/certificates/:nxt_hint:`bundle <Certificate bundle name>`/chain/0/subject/alt_names/0/
Expand Down
24 changes: 24 additions & 0 deletions source/configuration/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ The **tickets** option works as follows:
LoYjFVxpUFFOj4TzGkr5MsSIRMjhuh8RCsVvtIJiQ12FGhn0nhvvQsEND1+OugQ7
.. code-block:: console
$ openssl rand -base64 80
GQczhdXawyhTrWrtOXI7l3YYUY98PrFYzjGhBbiQsAWgaxm+mbkm4MmZZpDw0tkK
Expand Down Expand Up @@ -1971,14 +1973,20 @@ from the incoming requests:
HTTP/1.1 201 Created
.. code-block:: console
$ curl -i -X PUT http://localhost
HTTP/1.1 202 Accepted
.. code-block:: console
$ curl -i -X POST http://localhost
HTTP/1.1 203 Non-Authoritative Information
.. code-block:: console
$ curl -i --head http://localhost # Bumpy ride ahead, no route defined
HTTP/1.1 404 Not Found
Expand Down Expand Up @@ -2047,6 +2055,9 @@ it is considered empty.
.. code-block:: console
$ curl http://localhost/blog # Targets the 'blog' app
.. code-block:: console
$ curl http://localhost/sandbox # Targets the 'sandbox' app
A different approach puts the **Host** header field
Expand Down Expand Up @@ -2777,11 +2788,16 @@ won't be resolved.
.. code-block:: console
$ mkdir -p /www/localhost/static/ && cd /www/localhost/static/
.. code-block:: console
$ cat > index.html << EOF
> index.html
> EOF
.. code-block:: console
$ ln -s index.html /www/localhost/static/symlink
If symlink resolution is enabled
Expand All @@ -2794,6 +2810,8 @@ won't be resolved.
index.html
.. code-block:: console
$ curl http://localhost/symlink
index.html
Expand All @@ -2819,6 +2837,8 @@ won't be resolved.
index.html
.. code-block:: console
$ curl http://localhost/symlink
<!DOCTYPE html><title>Error 403</title><p>Error 403.
Expand Down Expand Up @@ -3666,6 +3686,8 @@ and set the **memory.high** limit:
cpuset cpu io memory pids
.. code-block:: console
# echo 1G > /sys/fs/cgroup:nxt_hint:`/staging/app <cgroup's path set in Unit configuration>`/memory.high
For more details
Expand Down Expand Up @@ -3986,6 +4008,8 @@ and rebuild the app.
0
.. code-block:: console
$ go env -w CGO_ENABLED=1
- If you installed Unit from the
Expand Down
9 changes: 9 additions & 0 deletions source/controlapi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ OpenAPI specification
.. code-block:: console
$ docker build --tag=unit-openapi -f unit-openapi.Dockerfile .
.. code-block:: console
$ docker run -d -p 8765:8765 -p 8080:8080 unit-openapi
Next, open **http://localhost:8765** in a browser.
Expand Down Expand Up @@ -366,6 +369,8 @@ provided you supply the right JSON:
# curl -X PUT -d '{ "pass": "applications/blogs" }' --unix-socket \
: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
.. code-block:: console
# curl -X PUT -d '"applications/blogs"' --unix-socket :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/pass
Expand Down Expand Up @@ -460,9 +465,13 @@ adding a URI-based route to the development version of the app:
]
EOF
.. code-block:: console
# curl -X PUT --data-binary @config.json --unix-socket \
:nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` http://localhost/config/routes
.. code-block:: console
# curl -X PUT -d '"routes"' --unix-socket \
:nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` 'http://localhost/config/listeners/*:8400/pass'
Expand Down
12 changes: 12 additions & 0 deletions source/howto/apollo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ using Unit:
.. code-block:: console
$ mkdir -p :nxt_ph:`/path/to/app/ <Path to the application directory; use a real path in your configuration>`
.. code-block:: console
$ cd :nxt_ph:`/path/to/app/ <Path to the application directory; use a real path in your configuration>`
.. code-block:: console
$ npm install @apollo/server graphql
.. code-block:: console
# npm link unit-http
#. Create the `middleware
Expand All @@ -35,6 +44,9 @@ using Unit:
.. code-block:: console
$ cd :nxt_ph:`/path/to/app/ <Path to the application directory; use a real path in your configuration>`
.. code-block:: console
$ npm init
Next, add the following code:
Expand Down
3 changes: 3 additions & 0 deletions source/howto/cakephp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ To run apps based on the `CakePHP <https://cakephp.org>`_ framework using Unit:
.. code-block:: console
$ cd :nxt_ph:`/path/to/ <Path where the application directory will be created; use a real path in your configuration>`
.. code-block:: console
$ composer create-project --prefer-dist cakephp/app:4.* :nxt_ph:`app <Arbitrary app name; becomes the application directory name>`
This creates the app's directory tree at **/path/to/app/**. Its
Expand Down
9 changes: 9 additions & 0 deletions source/howto/catalyst.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@ To run apps based on the `Catalyst
.. code-block:: console
$ cd :nxt_ph:`/path/to/ <Path where the application directory will be created; use a real path in your configuration>`
.. code-block:: console
$ catalyst.pl :nxt_ph:`app <Arbitrary app name; becomes the application directory name>`
.. code-block:: console
$ cd app
.. code-block:: console
$ perl Makefile.PL
Make sure the app's **.psgi** file includes the **lib/**
Expand Down
11 changes: 11 additions & 0 deletions source/howto/certbot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ Generating Certificates
# cat /etc/letsencrypt/live/www.example.com/fullchain.pem \
/etc/letsencrypt/live/www.example.com/privkey.pem > :nxt_ph:`bundle1.pem <Arbitrary certificate bundle's filename>`
.. code-block:: console
# curl -X PUT --data-binary @:nxt_ph:`bundle1.pem <Certificate bundle's filename>` \
--unix-socket :nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` \
http://localhost/certificates/:nxt_ph:`certbot1 <Certificate bundle name in Unit's configuration>`
Expand Down Expand Up @@ -170,9 +172,13 @@ For manual renewal and rollover:
1: Keep the existing certificate for now
2: Renew & replace the cert (may be subject to CA rate limits)
.. code-block:: console
# cat /etc/letsencrypt/live/www.example.com/fullchain.pem \
/etc/letsencrypt/live/www.example.com/privkey.pem > :nxt_ph:`bundle2.pem <Arbitrary certificate bundle's filename>`
.. code-block:: console
# curl -X PUT --data-binary @:nxt_ph:`bundle2.pem <Certificate bundle's filename>` \
--unix-socket :nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` \
http://localhost/certificates/:nxt_ph:`certbot2 <Certificate bundle name in Unit's configuration>`
Expand Down Expand Up @@ -229,9 +235,12 @@ For manual renewal and rollover:
# cat /etc/letsencrypt/live/cdn.example.com/fullchain.pem \
/etc/letsencrypt/live/cdn.example.com/privkey.pem > :nxt_hint:`cdn.example.com.pem <Arbitrary certificate bundle's filename>`
.. code-block:: console
# cat /etc/letsencrypt/live/www.example.com/fullchain.pem \
/etc/letsencrypt/live/www.example.com/privkey.pem > :nxt_hint:`www.example.com.pem <Arbitrary certificate bundle's filename>`
.. code-block:: console
# curl -X PUT --data-binary @:nxt_hint:`cdn.example.com.pem <Certificate bundle's filename>` \
--unix-socket :nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` \
Expand All @@ -241,6 +250,8 @@ For manual renewal and rollover:
"success": "Certificate chain uploaded."
}
.. code-block:: console
# curl -X PUT --data-binary @:nxt_hint:`www.example.com.pem <Certificate bundle's filename>` \
--unix-socket :nxt_ph:`/path/to/control.unit.sock <Path to Unit's control socket in your installation>` \
http://localhost/certificates/:nxt_hint:`www.example.com <Certificate bundle name in Unit's configuration>`
Expand Down
9 changes: 9 additions & 0 deletions source/howto/djangochannels.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@ To run Django apps using the |app| `framework
.. code-block:: console
$ cd :nxt_ph:`/path/to/venv/ <Path to the virtual environment; use a real path in your configuration>`
.. code-block:: console
$ source bin/activate
.. code-block:: console
$ pip install channels
.. code-block:: console
$ deactivate
#. Create a Django project. Here, we'll use the `tutorial chat app
Expand Down
25 changes: 25 additions & 0 deletions source/howto/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ official **hello, world** app:
.. code-block:: console
$ cd :nxt_ph:`/path/to/app/ <Directory where all app-related files will be stored; use a real path in your configuration>`
.. code-block:: console
$ mkdir webapp
.. code-block:: console
$ cat << EOF > webapp/wsgi.py
from flask import Flask
Expand All @@ -91,6 +97,9 @@ app:
.. code-block:: console
$ mkdir config
.. code-block:: console
$ cat << EOF > config/config.json
{
Expand All @@ -117,7 +126,13 @@ Finally, let's create **log/** and **state/** directories to store Unit
.. code-block:: console
$ mkdir log
.. code-block:: console
$ touch log/unit.log
.. code-block:: console
$ mkdir state
Our file structure so far:
Expand Down Expand Up @@ -315,12 +330,16 @@ Unit's state:
$ docker build --tag=:nxt_hint:`unit-expressapp <Arbitrary image tag>` .
.. code-block:: console
$ export UNIT=$( \
docker run -d \
--mount type=bind,src="$(pwd)/myapp/config.json",dst=/docker-entrypoint.d/config.json \
-p 8080:8080 unit-expressapp \
)
.. code-block:: console
$ curl -X GET localhost:8080
Hello, Unit!
Expand Down Expand Up @@ -358,16 +377,22 @@ the :ref:`control API <configuration-api>`:
...
EOF
.. code-block:: console
$ export UNIT=$( \
docker run -d \
--mount type=bind,src="$(pwd)/myapp/new-config.json",dst=/cfg/new-config.json \
unit-expressapp \
)
.. code-block:: console
$ docker exec -ti $UNIT curl -X PUT --data-binary @/cfg/new-config.json \
--unix-socket /var/run/control.unit.sock \
http://localhost/config
.. code-block:: console
$ docker exec -ti $UNIT curl -X PUT -d '"/www/newapp/"' \
--unix-socket /var/run/control.unit.sock \
http://localhost/config/applications/express/working_directory
Expand Down
9 changes: 9 additions & 0 deletions source/howto/dokuwiki.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@ using Unit:
.. code-block:: console
$ 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>`
.. code-block:: console
$ wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
.. code-block:: console
$ tar xvzf dokuwiki-stable.tgz :nxt_hint:`--strip-components <Avoids creating a redundant subdirectory>`=1
.. code-block:: console
$ rm dokuwiki-stable.tgz
#. .. include:: ../include/howto_change_ownership.rst
Expand Down
12 changes: 12 additions & 0 deletions source/howto/express.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ using Unit:
.. code-block:: console
$ mkdir -p :nxt_ph:`/path/to/app/ <Path to the application directory; use a real path in your configuration>`
.. code-block:: console
$ cd :nxt_ph:`/path/to/app/ <Path to the application directory; use a real path in your configuration>`
.. code-block:: console
$ npm install express --save
.. code-block:: console
# npm link unit-http
#. Create your Express `app
Expand All @@ -34,6 +43,9 @@ using Unit:
.. code-block:: console
$ cd :nxt_ph:`/path/to/app/ <Path to the application directory; use a real path in your configuration>`
.. code-block:: console
$ npm init
Next, add your application code:
Expand Down
Loading

0 comments on commit 147e7f0

Please sign in to comment.