Please check journalctl to find the real error that occurs before the lines you pasted. journalctl -u mojo_test.service
-Dan On Fri, Nov 24, 2017 at 5:34 AM, <david6...@gmail.com> wrote: > Hi Daniel, > Thank you deltail adivces. > I test follow your guide, but it's error same as I report before, it's in > Mojolicious 7.57. > I once change Mojolicious to 6.58 to test, it's still error, error output: > > [root@localhost ~]# systemctl status mojo_test.service > ● mojo_test.service - My Mojolicious application > Loaded: loaded (/usr/lib/systemd/system/mojo_test.service; enabled; > vendor preset: disabled) > Active: failed (Result: exit-code) since Fri 2017-11-24 18:23:20 CST; > 6s ago > Process: 2822 ExecStart=/root/perl5/bin/hypnotoad /home/mojo_user/ > mojo_test.pl (code=exited, status=2) > Process: 2820 ExecStartPre=/usr/bin/install -o mojo_user -g mojo_user -d > /var/log/mojo_test (code=exited, status=0/SUCCESS) > Process: 2819 ExecStartPre=/usr/bin/install -o mojo_user -g mojo_user -d > /run/mojo_test (code=exited, status=0/SUCCESS) > > Nov 24 18:23:20 localhost.localdomain hypnotoad[2822]: BEGIN > failed--compilation aborted at /usr/local/share/perl5/Mojo/Server/Daemon.pm > line 2. > Nov 24 18:23:20 localhost.localdomain hypnotoad[2822]: Compilation failed > in require at /usr/local/share/perl5/Mojo/Base.pm line 77. > Nov 24 18:23:20 localhost.localdomain hypnotoad[2822]: BEGIN > failed--compilation aborted at /usr/local/share/perl5/Mojo/Server/Prefork.pm > line 2. > Nov 24 18:23:20 localhost.localdomain hypnotoad[2822]: Compilation failed > in require at /usr/local/share/perl5/Mojo/Server/Hypnotoad.pm line 9. > Nov 24 18:23:20 localhost.localdomain hypnotoad[2822]: BEGIN > failed--compilation aborted at /usr/local/share/perl5/Mojo/Server/Hypnotoad.pm > line 9. > Nov 24 18:23:20 localhost.localdomain hypnotoad[2822]: Compilation failed > in require at /root/perl5/bin/hypnotoad line 20. > Nov 24 18:23:20 localhost.localdomain systemd[1]: mojo_test.service: > control process exited, code=exited status=2 > Nov 24 18:23:20 localhost.localdomain systemd[1]: Failed to start My > Mojolicious application. > Nov 24 18:23:20 localhost.localdomain systemd[1]: Unit mojo_test.service > entered failed state. > Nov 24 18:23:20 localhost.localdomain systemd[1]: mojo_test.service failed. > > > David > > > 在 2017年11月24日星期五 UTC+8上午8:45:57,Daniel Mantovani写道: > >> Hi, >> >> Type=forking should work just fine, I am not sure that with Type=simple >> you will have all the functionallity you can get from systemd. >> >> A couple of advices though: >> >> 1) to get more confortable with systemd, you probably want to replicate >> as much as possible the example in Mojolicious::Guides::Cookbook. It just >> works very well (https://metacpan.org/pod/dist >> ribution/Mojolicious/lib/Mojolicious/Guides/Cookbook.pod#Hypnotoad) >> >> 2) But if you need to have pidfile and log files outside your working >> directory (like in /run/your_app/hypnotoad.pid and >> /var/log/your_app/production.log etc...), this simple approach will not >> work, because you probably don't want to run your application with >> permissions so high it will be able to write in /run or /var/log >> directories. Instead you normally use a user with minimal permissions. >> Besides as far as I know hypnotoad requires to have permission rights in >> an already created directory for the pid file and also for the log file. >> >> If that is the case, what you can do is modify your original service file >> as follows: >> >> (I am supossing here that "/home/mojo_test.pl" is a typo, I guess if >> your user is "mojo_user" for instance, the path to the app will be >> something like "/home/mojo_user/mojo_test.pl") >> >> mojo_test.service >> [Unit] >> Description=My Mojolicious application >> Requires=network.target >> After=network.target >> >> [Service] >> Type=forking >> PIDFile=/run/mojo_test/hypnotoad.pid >> User=mojo_user >> Group=mojo_user >> PermissionsStartOnly=True >> ExecStartPre=/usr/bin/install -o mojo_user -g mojo_user -d /run/mojo_test >> ExecStartPre=/usr/bin/install -o mojo_user -g mojo_user -d >> /var/log/mojo_test >> ExecStart=/usr/local/bin/hypnotoad /home/mojo_user/mojo_test.pl >> ExecReload=/usr/local/bin/hypnotoad /home/mojo_user/mojo_test.pl >> KillMode=process >> >> [Install] >> WantedBy=multi-user.target >> >> Please check that in your configuration file you have the pid set as >> /run/mojo_test/hypnotoad.pid, and that when >> you define the path for the log file it goes inside /var/log/mojo_test >> directory, something like >> >> sub startup { >> ... >> $self->app->log->path('/var/log/mojo_test/production.log'); >> ... >> >> } >> >> About the zero downtime hypnotoad feature, with reload it should work >> without any problems (you can check that in the log file). If you restart >> instead of course it will kill the process and then start again, and you >> can check that also in the log file. >> >> One last thing, if you happen to have a recent version of systemd or you >> are allowed to install that (not my case unfortunatelly), you should check >> RuntimeDirectory= and LogsDirectory= directives. You can check if those are >> supported in your system with >> >> $ man systemd.directives >> >> If you have those, you will probably not need the ExecStartPre directives >> above, because the only thing these do is to create those directories. >> >> Hope it helps. >> BR, >> Daniel >> >> El jueves, 23 de noviembre de 2017, 13:36:10 (UTC-3), Boyd Duffee >> escribió: >>> >>> On 23/11/17 16:14, Dan Book wrote: >>> > I would not recommend running hypnotoad as a Type=simple service with >>> -f. >>> > This will not allow you to use hot-restarts via systemctl reload. >>> >>> Naively, I _can_ hot-restart with systemctl reload servicename, but now >>> you've got me worried. >>> Any idea why it's not advisable and is Type=forking the proper solution? >>> >>> -- >>> Boyd Duffee Keele University (01782) 734225 >>> DevOps - Student Facing Systems >>> >>> Some people are born on third base and go through life >>> thinking they hit a triple - Barry Switzer >>> >> -- > You received this message because you are subscribed to the Google Groups > "Mojolicious" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to mojolicious+unsubscr...@googlegroups.com. > To post to this group, send email to mojolicious@googlegroups.com. > Visit this group at https://groups.google.com/group/mojolicious. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+unsubscr...@googlegroups.com. To post to this group, send email to mojolicious@googlegroups.com. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.