Update: I corrected the below permission issue and I can read the log files dancer generates. There was a small code bug, fixed. So now the logs display nothing, but my POST request still just fails silently! :'(

Update 2 : I fixed it by just giving write permissions to /srv/www/domain.com/MyApp/logs

I have:

  1. An amazon-ec2 instance with the Amazon Linux AMI.
  2. It has apache2, running a perl dancer app on cgi as described here.

I have code doing OAuth with github API. Works perfect well on my machine but the final POST fails on amazon.

This may seem like a dev question, but I'm a beginner with linux sysadmin and I want clues as to how I should narrow my problem down.

This is my code:

my $browser                = LWP::UserAgent->new;
#alteast from the browser, seems like this POST never happens.
my $resp                   = $browser->post($github_post_url,
 client_id                  => $client_id,
 client_secret              => $client_secret, 
 code                       => $code,
 state                      => $state
die "error while fetching: ", $resp->status_line
unless $resp->is_success;

my %querystr = parse_query_str($resp->decoded_content);
my $acc = $querystr{access_token};

if($acc) {
        #code to retrive access token...
    redirect $github_auth_success;
    return redirect "/fail";#<<< THIS HAPPENS

The logs from here (tail /srv/www/domain.com/logs/error.log ) for this app say:

log directory /srv/www/domain.com/MyApp/bin/.. isn't writable/executable and can't chmod it at /usr/local/share/perl5/Dancer/Logger.pm line 16.

But my /bin directory IS writable! And executable for everyone!

  • How do I figure what is really happening here? Do I look at some other log somewhere?
  • Could amazon-ec2 be blocking the outgoing post? There doesn't seem to be any outbound rule I can set in the security groups?
  • The message isn't about the bin directory, it's about the MyApp/ directory - see the ".." after the "bin/". Is that directory writable / executable? – John Jan 9 '13 at 13:50
  • @John Oh so MyApp needs to be writable? I was wondering about those dots. – gideon Jan 9 '13 at 14:01
  • According to this error message it does, yes. – John Jan 9 '13 at 14:14
  • For some odd reasons there was a logs folder created under MyApp, I set this writable and I got the right error! :S Still can't getting to the botom of why that post doesn't work. – gideon Jan 9 '13 at 14:19
  • Seems there was a small bug with code I wrote to detect the response code from my LWP::UserAgent object. Fixed it, and seems the response code is Nothing!? – gideon Jan 9 '13 at 14:24

ls -al /srv/www/domain.com/MyApp/

What are the permissions set to on the bin directory?

Whatever user is running your perl script needs to have read/write access to that log directory.

You can chmod the directory (literally 'change mode') like so chmod +600 /srv/www/domain.com/MyApp/bin

It's better to put your log directory somewhere expected like /var/log/MyApp but that's beside the point. 'var' is for 'variable data', like logs. ;-)

  • If I do ls -al I get: drwxrwxrwx 2 ec2-user ec2-user 4096 Dec 30 07:46 bin – gideon Jan 9 '13 at 14:02
  • bah! Even after doing chmod 777 on both bin and MyApp the log gives me the same thing!!!? – gideon Jan 9 '13 at 14:06
  • Hey Joseph!I updated my question – gideon Jan 9 '13 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.