github.com/olivere/camlistore@v0.0.0-20140121221811-1b7ac2da0199/website/run.pl (about)

     1  #!/usr/bin/perl
     2  
     3  use strict;
     4  use FindBin qw($Bin);
     5  
     6  my $logdir = "$Bin/../logs";
     7  
     8  unless (-d $logdir) {
     9      mkdir $logdir, 0700 or die "mkdir: $!";
    10  }
    11  
    12  my $HOME = $ENV{HOME};
    13  chdir $Bin or die;
    14  
    15  print STDERR "Running camweb in $Bin on port 8080\n";
    16  
    17  my $in_prod = -e "$HOME/etc/ssl.key"; # heuristic. good enough.
    18  
    19  my @args;
    20  push @args, "go", "run", "camweb.go", "logging.go", "godoc.go", "format.go", "dirtrees.go", "email.go";
    21  push @args, "--root=$Bin";
    22  push @args, "--logdir=$logdir";
    23  push @args, "--buildbot_host=build.camlistore.org";
    24  push @args, "--buildbot_backend=http://c1.danga.com:8080";
    25  push @args, "--also_run=$Bin/scripts/run-blobserver";
    26  if ($in_prod) {
    27      push @args, "--email_dest=camlistore-commits\@googlegroups.com";
    28      push @args, "--http=:8080";
    29      push @args, "--https=:4430";
    30      push @args, "--tlscert=$HOME/etc/ssl.crt";
    31      push @args, "--tlskey=$HOME/etc/ssl.key";
    32      while (1) {
    33          system(@args);
    34          print STDERR "Exit: $?; sleeping/restarting...\n";
    35          sleep 5;
    36      }
    37  } else {
    38      my $pass_file = "$ENV{HOME}/.config/camlistore/camorg-blobserver.pass";
    39      unless (-s $pass_file) {
    40          `mkdir -p $ENV{HOME}/.config/camlistore/`;
    41          open (my $fh, ">$pass_file");
    42          print $fh "foo\n";
    43          close($fh);
    44      }
    45      push @args, "--http=127.0.0.1:8080"; # localhost avoids Mac firewall warning
    46      push @args, @ARGV;
    47      exec(@args);
    48      die "Failed to exec: $!";
    49  }