cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
Serve your application

Serve your Cutelyst application using cutelystd4-qt6.

cutelystd4-qt6 is the main executable to serve your Cutelyst applications to your users. cutelyst4-qt6 on the other site is meant to help you with developing your application and to start a development server. cutelystd4-qt6 can serve your application on its own but can also act behind a frontend proxy like Apache or nginx. It provides support for multiple sockets of different types like HTTP/1, HTTP/2 and FastCGI. The page cutelystd4-qt6 provides information about all available options. See also Serve static files to learn more about how to serve static files. Options for cutelystd4-qt6 can also be specified in configuration files loaded with --ini or --json, read Configure your application to see how to use them.

Directly use cutelystd4-qt6

Serve app with HTTP

Serve your Cutelyst application on port 3000 bound to localhost with HTTP/1 procotol:

cutelystd4-qt6 -M --lazy -a /path/to/cutelystapp.so --h1 localhost:3000

Serve app with HTTPS

To serve your application using the HTTPS protocol, you also need a SSL/TLS certificate and a key file in PEM format of either type RSA or EC. In the example we will create a HTTPS socket on port 3000 bound to all interfaces and use ALPN to negotiate to HTTP/2.

cutelystd4-qt6 -M --lazy -a /path/to/cutelystapp.so --hs1 :3000,/path/to/cert.pem,/path/to/eckey.pem,ec --https-h2

Use cutelystd4-qt6 behind Apache

Use FastCGI proxy

To use the cutelystd4-qt6 behind an Apache frontend proxy, you can use the FastCGI protocol bound to a local UNIX socket. In the example we will run the Cutelyst server under dedicated user and group ids and will protect the socket file by changing the group owner and access rights, so that only Apache (belonging to group www) and cutelystd4-qt6 have access to the socket. This normally requires that your start cutelystd4-qt6 as root:

cutelystd4-qt6 -M --lazy -a /path/to/cutelystapp.so \
               --fastcgi-socket /run/cutelystapp.sock \
               --socket-access ug --chown-socket appuser:www \
               --uid appuser --gid appuser

For Apache we create a virtual host configuration for our application. We will also use Apache to server our static assets:

<VirtualHost :80>
Servername app.example.com:80
ProxyFCGIBackendType GENERIC
ProxyPass / unix:/run/cutelystapp.sock|fcgi://cutelystapp/
# serve our static assets via apache
Alias /assets /path/to/our/static/assets
<Location /assets>
ProxyPass !
Require all granted
</Location>
</VirtualHost>

Stop the cutelystd4-qt6 server

cutelystd4-qt6 provides the --stop option to stop a server instance identified by a PID written to a file using --pidfile or -pidfile2 option.

Start the server and write the PID to a file:

cutelystd4-qt6 -M --lazy -a /path/to/cutelystapp.so --h1 localhost:3000 --pidfile /run/cutelystapp.pid

Stop the server using the PID file:

cutelystd4-qt6 --stop /run/cutelystapp.pid

Use systemd

On GNU/Linux based operating systems you may want to use systemd to manage your Cutelyst application services. Cutelyst supports systemd notifications. Here is an example systemd service file implementation using a local FastCGI socket.

[Unit]
Description=My little application
After=network.target
Before=httpd.service nginx.service lighttpd.service
[Service]
Type=notify
PIDFile=${RUNTIME_DIRECTORY}/myapp.pid
ExecStart=/usr/bin/cutelystd4-qt6 -M --lazy -a /path/to/myapp.so --pidfile ${RUNTIME_DIRECTORY}/myapp.pid --fastcgi-socket ${RUNTIME_DIRECTORY}/myapp.sock --socket-access ug --chown-socket myappuser:www --uid myappuser --gid myappgroup
ExecStop=/usr/bin/cutelyst4d-qt6 --stop ${RUNTIME_DIRECTORY}/myapp.pid
NotifyAccess=all
RuntimeDirectory=myapp
[Install]
WantedBy=multi-user.target