Perl Project Improvement(1) Perl Installation and CPAN

PerlProjectImprovement(1)PerlInstallationandCPAN

>perl-v

Thisisperl5,version16,subversion0(v5.16.0)builtfordarwin-2level

CPANinstallation

Log::Log4perl

YAML::XS

Data::Dumper

DBI

IOC

Redis

Time::Piece

Path::Class

autodie

Thread::Queue

DBD::mysql

threads

IfCPANinstallisnotworking,youmayneedforceinstall.

1InstallDBIonMAC

>cpanApp::cpanminus

>cpanmDBI

>perl-MCPAN-e'shell'

cpan>getDBD::mysql

>cd/usr/local/lib

>sudoln-s/usr/local/mysql/lib/*.dylib.

>cd~/.cpan/build/DBD*/

>sudoperlMakefile.PL--testuser='test'

sudomakeandsudomakeinstall

>sudoln-s/usr/local/mysql/lib/libmysqlclient.18.dylib/usr/local/lib/libmysqlclient.18.dylib

>exportDLYD_LIBRARY_PATH=/usr/local/mysql/lib

ShowthePerlDirectory:

>perl-e'printjoin("\n",@INC)."\n";'

/home/ec2-user/perl5/lib/perl5/x86_64-linux-thread-multi

/home/ec2-user/perl5/lib/perl5

/usr/local/lib64/perl5

/usr/local/share/perl5

/usr/lib64/perl5/vendor_perl

/usr/share/perl5/vendor_perl

/usr/lib64/perl5

/usr/share/perl5

.

RunthePerltestcases

>provet/*

2ManuallyInstallPerl

http://perldoc.perl.org/perlmacosx.html

http://www.cpan.org/src/

>curl-Ohttp://www.cpan.org/src/perl-5.22.0.tar.gz

>./Configure-des-Dprefix=/Users/carl/tool/perl-5.22.0

MakeandMakeInstall

Buildwithsupportingforthreads

>./Configure-des-Dusethreads-Dprefix=/Users/carl/tool/perl-5.22.0

threadsandforks

http://stackoverflow.com/questions/22036985/error-using-thread-module-this-perl-not-built-to-support-threads

Icheckedtheversiononalltheservers,Iamusingthisoldversion.

>perl-v

Thisisperl5,version16,subversion3(v5.16.3)builtforx86_64-linux-thread-multi

(with25registeredpatches,seeperl-Vformoredetail)

SoIwillmanuallyinstalltheversiononCentOSDockerImage

3ManuallyInstallPerlonCentOSDockerImage

>wgethttp://www.cpan.org/src/5.0/perl-5.16.3.tar.gz

>./Configure-des-Dprefix=/tool/perl-5.16.3

ErrorMessage:

Ican'tfindmakeorgmake,andmylifedependsonit.

GofindapublicdomainimplementationorfixyourPATHsetting!

Solution:

yuminstall-ygcc

yuminstall-ymake

https://github.com/luohuazju/sillycat-docker/blob/master/centos7-nginx/Dockerfile

>make

>makeinstall

Ifweinstallthatondockerimage,wecanignorethe-Dprefix,becausewedonotwanttosetupPATH.

ThiscanbypasstheCPANcommandconfirmation.

exportPERL_MM_USE_DEFAULT=1

cpan-fiLog::Log4perlYAML::XS

cpan-fiLog::Log4perlYAML::XSData::DumperDBIIOCRedisTime::PiecePath::ClassautodieThread::QueueDBD::mysqlthreads

cpanDBIx::Connector

or

cpanDBIx::ConnectorLog::Log4perl

cpan-fiautodieThread::Queuethreads

Installcpanm

>curl-Lhttps://cpanmin.us|perl-App::cpanminus

Or

cpanApp::cpanminus

Eventhisdoesnotwork

>cpanm--notestDBD::mysql

ErrorMessage:

Can'texec"mysql_config":NosuchfileordirectoryatMakefile.PLline73.

Cannotfindthefile'mysql_config'!YourexecutionPATHdoesn'tseem

notcontainthepathtomysql_config.Resortingtoguessedvalues!

Solution:

yuminstallmysql-devel

Thedockerfileconfigurationsareasfollow

Dockerfile

#PrepretheOS

FROMcentos:7

MAINTAINERCarlLuo<[email protected]>

ENVDEBIAN_FRONTENDnoninteractive

ENVPERL_MM_USE_DEFAULT1

RUNyuminstall-ygccmakewget

RUNyuminstall-ymysql-devel

RUNmkdir/install/

WORKDIR/install/

#installperl

RUNwgethttp://www.cpan.org/src/5.0/perl-5.16.3.tar.gz

RUNtarzxvfperl-5.16.3.tar.gz

WORKDIR/install/perl-5.16.3

RUN./Configure-des-Dusethreads

RUNmake&&makeinstall

RUNcpan-fiLog::Log4perlYAML::XSData::DumperDBIIOCRedisTime::PiecePath::Class

RUNcpan-fiautodieThread::Queuethreads

RUNcpan-fiDBIx::Connector

RUNcpanDBD::mysql

#InstalltheApplication

RUNmkdir/share/

WORKDIR/share/

ADDdist/jobs-producer-1.0.tgz/share/

RUNmkdir-p/mnt/ad_feed

RUNmkdir-p/mnt5/ad_feed

#StarttheApplication

RUNmkdir-p/app/

ADDstart.sh/app/

WORKDIR/app

CMD["./start.sh"]

Makefile

IMAGE=sillycat/jobs-producer

TAG=1.0

NAME=jobs-producer

REPOSITORY=registry.sillycat.com

push-local:

dockerpush$(REPOSITORY)/$(IMAGE):$(TAG)

app-clean:

rm-frdist

rm-fr$(NAME)-$(TAG)

app-init:

curl-sShttps://getcomposer.org/installer|php

phpcomposer.pharinstall

app-build:

mkdir-p./$(NAME)-$(TAG)/logs

mkdir-p./dist

cp-r./conf./$(NAME)-$(TAG)/

cp-r./lib./$(NAME)-$(TAG)/

cp-r./src./$(NAME)-$(TAG)/

cp-r./vendor./$(NAME)-$(TAG)/

cp*.pl./$(NAME)-$(TAG)/

tar-cvzf./dist/$(NAME)-$(TAG).tgz./$(NAME)-$(TAG)

docker-context:

build:docker-context

sudodockerbuild-t$(REPOSITORY)/$(IMAGE):$(TAG).

run-stage:

sudodockerrun-v/opt/jobs-producer/logs:/share/$(NAME)-$(TAG)/logs-v/mnt/ad_feed:/mnt/ad_feed-v/mnt5/ad_feed:/mnt5/ad_feed-d-eRUNNING_ENV=stage--name$(NAME)$(REPOSITORY)/$(IMAGE):$(TAG)

debug:

sudodockerrun-v/opt/jobs-producer/logs:/share/$(NAME)-$(TAG)/logs-v/mnt/ad_feed:/mnt/ad_feed-v/mnt5/ad_feed:/mnt5/ad_feed-ti-eRUNNING_ENV=stage--name$(NAME)$(REPOSITORY)/$(IMAGE):$(TAG)/bin/bash

clean:

sudodockerstop${NAME}

sudodockerrm${NAME}

logs:

sudodockerlogs${NAME}

publish:

sudodockerpush${IMAGE}

start.sh

#!/bin/sh-ex

cd/share/jobs-producer-1.0

perlJobProducerApp.pl

References:

log4perl

http://unmi.cc/perl-log4perl-user-guide/

IOC

http://collaboration.cmc.ec.gc.ca/science/rpn/biblio/ddj/Website/articles/TPJ/2005/0501/0501a/0501a.html

http://perlalchemy.blogspot.com/2011/01/dependency-injection-or-removing.html

http://www.drdobbs.com/web-development/inversion-of-control-in-perl/184416179#l1

http://search.cpan.org/~stevan/IOC-0.29/lib/IOC.pm

ConfigurationFile

http://perltricks.com/article/29/2013/9/17/How-to-Load-YAML-Config-Files

MysqlConnection

http://search.cpan.org/~capttofu/DBD-mysql-4.033/lib/DBD/mysql.pm

upgradeversionandre-install

installDBIonmac

http://stackoverflow.com/questions/19565553/problems-with-perl-dbi-dbd-on-osx-10-9-mavericks

tap::harnesstestsuite

http://www.4byte.cn/question/1518155/tap-harness-perl-tests-tee-output.html

相关推荐