cutelyst
4.5.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
|
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.
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
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
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:
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
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.