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 (hello.pl) 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'; app->start; __DATA__ @@index.html.ep <html> <body> Hello! </Body> </html>
Start starman.
starman hello.pl
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 hello.pl
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/app1.pl'
I am changing the user and running it by using su's -c command. The office should be run by the owner of hello.pl. 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.
/etc/rc.d/rc.local