From d53ee53ad8a9a50e87499c3daf7f4beb49cd862b Mon Sep 17 00:00:00 2001 From: eleksir Date: Sat, 19 Sep 2020 14:48:29 +0300 Subject: [PATCH] Use Cwd::utf8 to cope with returning string ut8-ness * Use Cwd::utf8 * Sort cpanfile require, remove duplicates, add Cwd::utf8 * Add check on first call of abs_path() --- bin/aleesa-telegram-bot | 9 ++++++++- cpanfile | 11 ++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bin/aleesa-telegram-bot b/bin/aleesa-telegram-bot index ddd2702..b50e70f 100755 --- a/bin/aleesa-telegram-bot +++ b/bin/aleesa-telegram-bot @@ -18,6 +18,8 @@ BEGIN { } use lib ("$workdir/lib", "$workdir/vendor_perl", "$workdir/vendor_perl/lib/perl5"); +no Cwd; +use Cwd::utf8 qw(chdir abs_path); use POSIX qw(setgid setuid setsid); use File::Path qw(make_path); use File::Basename qw(basename dirname); @@ -70,8 +72,13 @@ if ($< == 0) { # double fork attach to /dev/null all stdio and go background daemonize (); +unless (defined($apath)) { + logger ("Unable to get abs_path: $!"); + die "Unable to get abs_path: $!\n"; +}; + # write pidfile -my $pidfile = sprintf ("%s/%s.pid", $piddir, basename (abs_path ($0))); +my $pidfile = sprintf ("%s/%s.pid", $piddir, basename ($apath)); logger ("Creating pidfile at $pidfile"); open (PID, ">", $pidfile) or die "Error opening $pidfile: $!\n"; print PID $$ or die "Error writing to $pidfile: $!\n"; diff --git a/cpanfile b/cpanfile index 25ebd87..7d262fd 100644 --- a/cpanfile +++ b/cpanfile @@ -1,14 +1,15 @@ -requires 'local::lib'; -requires 'JSON'; -requires 'Hailo'; -requires 'Telegram::Bot'; +requires 'Cwd::utf8'; requires 'DB_File'; requires 'Digest::MD5'; requires 'Encode'; -requires 'File::Path'; requires 'File::Basename'; +requires 'File::Path'; requires 'HTTP::Tiny'; requires 'Hailo'; +requires 'JSON'; requires 'JSON::XS'; +requires 'JSON::PP'; requires 'Mojo::Base'; +requires 'Telegram::Bot'; requires 'URI::URL'; +requires 'local::lib';