Deploy the Mojolicious (PSGI) app with Starman

Try launching a Mojolicious application using a Perl prefolk server called Starman. It's a good choice for running Mojolicious applications in Starman production.

cpanm Starman

The following is a PSGI app ( written in Mojolicious::Lite. Please note that only comments should be placed between "app->start" and "__DATA__".

use strict;
use warnings;

use Mojolicious::Lite;

get'/' =>'index';



<html> <body> Hello! </Body> </html>

Start starman.


Now you can see that the Mojolicious app is running by accessing the following:

http: // localhost: 5000 /

Use the "--port" option to specify the port.

starman --port = 3000

Production operation

For production operations, you'll want to run it in the background and run your application at the same time you start the server. In such a case, do the following. Run it as the root user.

#Start the server
su --kimoto -c'starman --port = 3000 --daemonize --pid = / home / kimoto / labo / pid /home/kimoto/labo/'

I am changing the user and running it by using su's -c command. The office should be run by the owner of You can daemonize the server with the --daemonize option. The --pid option specifies the file to write the process ID of the server. This will be the information you need when you stop the server.

To stop the server, pass the process ID to the kill command. When combined with xarg, you can pass the process ID written in the file to kill.

#Server outage
cat / home / kimoto / labo / pid | xargs kill

If you want to start the Mojolicious application when Linux starts, add the description of starting the server to the following file.


Associated Information