newperldeveloper has asked for the wisdom of the Perl Monks concerning the following question:

I am starting my application using a service file. I am trying to create a pid file that mojolicious needs, however what I have tried is not working. Here is my service file.

[Unit] Description=Perl App [Service] Type=forking User=www-data Group=www-data Environment=movielog=/tmp/movie-app/movie.log UMask=007 ExecStart=/webapp/movie-app/local/bin/hypnotoad /webapp/movie-app/scri +pt/movie ExecReload=/webapp/movie-app/local/bin/hypnotoad /webapp/movie-app/scr +ipt/obdaac ExecStop=/webapp/movie-app/local/bin/hypnotoad --stop /webapp/movie-ap +p/script/obdaac TimeoutStopSec=5 PIDFile=/tmp/movie-app/hypnotoad.pid KillMode=mixed [Install] WantedBy=multi-user.target

My hypnotoad file looks like

#!/usr/bin/perl use Mojo::Base -strict; use Mojo::Server::Hypnotoad; use Mojo::Util qw(extract_usage getopt); getopt 'f|foreground' => \$ENV{HYPNOTOAD_FOREGROUND}, 'h|help' => \my $help, 's|stop' => \$ENV{HYPNOTOAD_STOP}, 't|test' => \$ENV{HYPNOTOAD_TEST}; die extract_usage if $help || !(my $app = shift || $ENV{HYPNOTOAD_APP} +); Mojo::Server::Hypnotoad->new->run($app,pid_file => '/tmp/movie-app/hyp +notoad.pid');

Perl keeps trying to create the pid file in the application directory /webapp/movie-app/script/movie and that is causing an error. How do I get hypnotoad to create the pid file in the /tmp/movie-app/hypnotoad.pid location.

Replies are listed 'Best First'.
Re: Creating a pidfile for mojolicious is giving an error errors
by beech (Parson) on Nov 06, 2020 at 03:44 UTC
      Thank you for your help, I added pid_file to the config. I am not to really familiar with mojolicious.