Catalyst
To run apps based on the Catalyst 5.9+ framework using Unit:
-
Install Unit with a Perl language module.
-
Install Catalyst’s core files.
-
Create a Catalyst app. Here, let’s store it at /path/to/app/:
$ cd /path/to/ # Path where the application directory will be created; use a real path in your configuration
$ catalyst.pl app # Arbitrary app name; becomes the application directory name
$ cd app
$ perl Makefile.PL
Make sure the app’s .psgi file includes the lib/ directory:
use lib 'lib'; use app;
-
Change ownership:
Run the following command (as root) so Unit can access the application directory (If the application uses several directories, run the command for each one):
# chown -R unit:unit /path/to/app/ # User and group that Unit's router runs as by default
The unit:unit user-group pair is available only with official packages , Docker images, and some third-party repos. Otherwise, account names may differ; run theps aux | grep unitd
command to be sure.For further details, including permissions, see the security checklist.
-
Next, prepare the Catalyst configuration for Unit (use real values for script and working_directory):
{ "listeners": { "*:80": { "pass": "applications/catalyst" } }, "applications": { "catalyst": { "type": "perl", "working_directory": "/path/to/app/", "_comment_working_directory": "Needed to use modules from the local lib directory; use a real path in your configuration", "script": "/path/to/app/app.psgi", "_comment_script": "Path to the application directory; use a real path in your configuration" } } }
-
Upload the updated configuration.
Assuming the JSON above was added to
config.json
. Run the following command as root:# curl -X PUT --data-binary @config.json --unix-socket \ /path/to/control.unit.sock \ # Path to Unit's control socket in your installation http://localhost/config/ # Path to the config section in Unit's control API
After a successful update, your app should be available on the listener’s IP address and port: