Mercurial > pub > site.implab
changeset 0:aac1085b256d
initial commit
author | cin |
---|---|
date | Sat, 15 Mar 2014 00:34:33 +0400 |
parents | |
children | f1ce08199a08 |
files | .hgignore .includepath .project deploy.pl httpd.conf lib/Implab/Web/Resources/Root.pm my.cnf public_html/cgi-bin/_config.pm public_html/cgi-bin/handler.pl serve.pl view/templates/Collection.tt view/templates/Compound.tt view/templates/Library.tt view/templates/Member.tt |
diffstat | 10 files changed, 275 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Sat Mar 15 00:34:33 2014 +0400 @@ -0,0 +1,3 @@ +syntax: glob +config/ +mysql-data/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.includepath Sat Mar 15 00:34:33 2014 +0400 @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<includepath> + <includepathentry path="/home/sergey/workspace.web/Impl/Lib" /> + <includepathentry path="/home/sergey/workspace.web/benzin/lib" /> +</includepath> +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.project Sat Mar 15 00:34:33 2014 +0400 @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>implab</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.epic.perleditor.perlbuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.epic.perleditor.perlnature</nature> + </natures> +</projectDescription>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deploy.pl Sat Mar 15 00:34:33 2014 +0400 @@ -0,0 +1,11 @@ +#!/usr/bin/perl -w +use strict; + +my @dirs = qw( + doxygen-data + mysql-data +); + +mkdir $_ foreach grep not(-e $_), @dirs; + +`mysql_install_db --datadir=./mysql-data`; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/httpd.conf Sat Mar 15 00:34:33 2014 +0400 @@ -0,0 +1,92 @@ + +LoadModule ldap_module /usr/lib64/apache2-prefork/mod_ldap.so +LoadModule authnz_ldap_module /usr/lib64/apache2-prefork/mod_authnz_ldap.so +LoadModule actions_module /usr/lib64/apache2-prefork/mod_actions.so +LoadModule alias_module /usr/lib64/apache2-prefork/mod_alias.so +LoadModule auth_basic_module /usr/lib64/apache2-prefork/mod_auth_basic.so +LoadModule authz_host_module /usr/lib64/apache2-prefork/mod_authz_host.so +LoadModule authz_core_module /usr/lib64/apache2-prefork/mod_authz_core.so +LoadModule authz_user_module /usr/lib64/apache2-prefork/mod_authz_user.so +LoadModule cgi_module /usr/lib64/apache2-prefork/mod_cgi.so +LoadModule dir_module /usr/lib64/apache2-prefork/mod_dir.so +LoadModule env_module /usr/lib64/apache2-prefork/mod_env.so +LoadModule expires_module /usr/lib64/apache2-prefork/mod_expires.so +LoadModule log_config_module /usr/lib64/apache2-prefork/mod_log_config.so +LoadModule mime_module /usr/lib64/apache2-prefork/mod_mime.so +LoadModule negotiation_module /usr/lib64/apache2-prefork/mod_negotiation.so +LoadModule setenvif_module /usr/lib64/apache2-prefork/mod_setenvif.so +LoadModule rewrite_module /usr/lib64/apache2-prefork/mod_rewrite.so +LoadModule perl_module /usr/lib64/apache2/mod_perl.so + +ServerName 127.0.0.1 +DocumentRoot public_html +Listen 2077 +PidFile httpd.pid + +ErrorLog httpd.log +CustomLog httpd.log "%h %l %u %t \"%r\" %>s %b" + +PerlSwitches -T + +<Perl > + use Cwd qw(cwd); + use File::Spec(); + + my ($base) = (cwd() =~ m/(.*)/); + $IMPL::Config::AppBase = $base; + $IMPL::Config::ConfigBase = File::Spec->catdir($base, 'config'); + + push @INC, File::Spec->catdir($base,'lib'); + push @INC, File::Spec->catdir($base,'../Impl/Lib'); + + require Benzin::Apache::CookieAuth; + require Benzin::Web::Application; +</Perl> + +Alias /favicon.ico public_html/favicon.ico +Alias /js/ public_html/js/ +Alias /css/ public_html/css/ +Alias /static/ public_html/static/ +Alias /images/ public_html/images/ + +Alias / public_html/cgi-bin/handler.pl/ + +<Directory public_html> + AllowOverride none + Require all granted +</Directory> + +<Directory public_html/cgi-bin > + #SetHandler perl-script + #PerlHandler Benzin::Web::Application + + SetHandler cgi-script + Options +ExecCGI +</Directory> + +<Location /> + #AuthName "Your collab account" + #AuthType benzin + #PerlAuthenHandler Benzin::Apache::CookieAuth + + #Require valid-user +</Location> + +<Location /user> + Require all granted +</Location> +<Location /js> + Require all granted +</Location> +<Location /css> + Require all granted +</Location> +<Location /static> + Require all granted +</Location> +<Location /images> + Require all granted +</Location> +<Location /favicon.ico> + Require all granted +</Location>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/Implab/Web/Resources/Root.pm Sat Mar 15 00:34:33 2014 +0400 @@ -0,0 +1,26 @@ +package Implab::Web::Resources::Root; +use strict; + +use IMPL::declare { + require => { + LibraryResource => '-Benzin::Web::Resources::Doxygen::Library', + UserResource => '-Benzin::Web::Resources::UserResource' + }, + base => [ + 'IMPL::Web::Application::Resource' => '@_' + ] +}; + +sub children { + return { + library => { + class => LibraryResource + }, + user => { + class => UserResource, + components => [qw(login logout passwd edit)] + } + }; +} + +1; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/my.cnf Sat Mar 15 00:34:33 2014 +0400 @@ -0,0 +1,5 @@ + +[server] + +datadir = "./mysql-data" +socket = "/tmp/mysql-implab.sock"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/public_html/cgi-bin/_config.pm Sat Mar 15 00:34:33 2014 +0400 @@ -0,0 +1,43 @@ +use strict; +use warnings; + +use File::Spec; +use Carp; + +my @dirs; + +BEGIN { + $Carp::Verbose = 0; # set this to 1 to enable carp traces + my $cwd = (File::Spec->splitpath($ENV{SCRIPT_FILENAME} || $0))[1]; + @dirs = File::Spec->splitdir($cwd); + + #go two dirs up + pop @dirs unless pop @dirs; # remove empty dir in case of trailing / + pop @dirs; + + push @INC, File::Spec->catdir(@dirs,'lib'); + + package IMPL::Config; + + our $AppBase = File::Spec->catdir(@dirs); + our $ConfigBase = File::Spec->catdir(@dirs,'config'); + + package IMPL::Web::Application::ControllerUnit; + + our @schemaInc; + + push @schemaInc, File::Spec->catdir(@dirs,'schema'); + + package main; + + my $bootstrap = File::Spec->catfile($ConfigBase, 'bootstrap.pm'); + if( -f $bootstrap ) { + do $bootstrap; + + ($! ? die($@,$!) : die($@) )if $@; + + } + +} + +1; \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/public_html/cgi-bin/handler.pl Sat Mar 15 00:34:33 2014 +0400 @@ -0,0 +1,22 @@ +#!/usr/bin/perl -wT +#-d:NYTProf +use strict; + +BEGIN { + require "./_config.pm"; +} + +use CGI; +use IMPL::require { + TApp => 'Benzin::Web::Application' +}; + +eval { + my $instance = TApp->spawn; + + $instance->Run(); +}; +if ($@) { + print CGI::header(-status => 500, type => 'text/plain'); + print $@; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/serve.pl Sat Mar 15 00:34:33 2014 +0400 @@ -0,0 +1,50 @@ +#!/usr/bin/perl +use strict; +use warnings; +use POSIX qw(setsid); + +my ($pidApache,$pidMysql,$pidTailf); + +print "starting apache\n"; +unless($pidApache = fork()) { + setsid(); + exec('/usr/sbin/httpd2 -d . -f httpd.conf -DNO_DETACH -DFOREGROUND'); +} + +print "starting mysql\n"; +unless($pidMysql = fork()) { + #setsid(); + open STDERR, '>mysql.log'; + open STDOUT, '>mysql.log'; + exec('/usr/sbin/mysqld --defaults-file=./my.cnf'); +} + +print "press any key to stop\n"; +print "opening apache log\n"; +unless($pidTailf = fork()) { + #setsid(); + exec('/usr/bin/tailf httpd.log'); +} + +getc; + +print "SHUTDOWN\n"; + +print "shutdown apache ($pidApache)\n"; +kill 28, $pidApache; +waitpid $pidApache, 0; +print "apache exited\n"; + +print "shutdown mysql ($pidMysql)\n"; +kill 15, $pidMysql; +waitpid $pidMysql, 0; +print "mysql exited\n"; + + +print "closing log ($pidTailf)\n"; +kill 9, $pidTailf; +waitpid $pidTailf, 0; + +print "done\n"; + +exit; \ No newline at end of file