File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ export HTTPD_EXPOSE_PORT
3333export PLACKUP
3434export CMD
3535
36+ # mt-watcher container
37+ export PERL_FNS_NO_OPT
38+
3639
3740# override variables
3841ENV_FILE =.env
Original file line number Diff line number Diff line change 1+ # !/usr/bin/env perl
2+
3+ use strict;
4+ use warnings;
5+
6+ use Cwd qw( getcwd) ;
7+ use Filesys::Notify::Simple;
8+
9+ if ( $ENV {DISABLE_MT_WATCHER } ) {
10+ warn (' mt-watcher container is disbled.' );
11+ exit ;
12+ }
13+
14+ # wait for `make me` to complete
15+ sleep (5);
16+
17+ my $mt_home = $ENV {MT_HOME } || getcwd();
18+ $mt_home =~ s { /+$} {} ; # remove trailing slash
19+
20+ my @files = ( map ( {" $mt_home /$_ " } qw( addons extlib lib plugins) ), glob (" $mt_home /*.cgi" ) );
21+ my $watcher = Filesys::Notify::Simple-> new( \@files );
22+ while (1) {
23+ $watcher -> wait(
24+ sub {
25+ my @paths = grep {
26+
27+ # exclude files other than "*.cgi" at the top level
28+ $_ =~ m {$mt_home /(?:[^/]+\. cgi|.*?/)} ;
29+ } map { $_ -> {path } } @_ ;
30+
31+ return unless @paths ;
32+
33+ print ( join ( " \n " , @paths ) . " \n " );
34+ system (' docker kill -s HUP mt_mt_1' );
35+
36+ # throttling
37+ sleep (1);
38+ }
39+ );
40+ }
Original file line number Diff line number Diff line change 1+ FROM perl:5.34
2+
3+ ENV DOCKER_VERSION=20.10.7
4+
5+ # # docker
6+ RUN set -ex \
7+ \
8+ && mkdir /tmp/docker \
9+ && cd /tmp/docker \
10+ && curl -sL https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz -o docker.tgz \
11+ && tar zxf docker.tgz \
12+ && mv docker/docker /usr/bin/docker \
13+ && rm -fr /tmp/docker
14+
15+ # # cpan libraries
16+ RUN set -ex \
17+ \
18+ && cpanm Filesys::Notify::Simple Linux::Inotify2
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3- reload_options=" ` ls * .cgi | sed -e ' s/^/-R /' ` ` ls mt-static | grep -v support | sed -e ' s/^/-R mt-static\//' ` "
4-
53exec starman \
64 -MCGI \
75 -MFile::Spec \
@@ -12,16 +10,8 @@ exec starman \
1210 -MDBI \
1311 -MDBD::mysql \
1412 -MImage::Magick \
15- -R addons \
16- -R alt-tmpl \
17- -R default_templates \
18- -R extlib \
19- -R lib \
20- -R php \
21- -R plugins \
22- -R search_templates \
23- -R themes \
24- -R tmpl \
25- -R tools \
26- $reload_options \
13+ -E production \
14+ --port=80 \
15+ --workers=2 \
16+ --pid=$MT_PID_FILE_PATH \
2717 " $@ "
Original file line number Diff line number Diff line change @@ -2,6 +2,20 @@ version: "3"
22services :
33 mt :
44 restart : always
5- command : " ${PLACKUP:-/usr/local/lib/mt/bin/plackup-mt -E production -L Shotgun --port=80 --workers=2 --pid=/tmp/mt.psgi.pid} /var/www/cgi-bin/mt/mt.psgi"
5+ command : " ${PLACKUP:-/usr/local/lib/mt/bin/plackup-mt} /var/www/cgi-bin/mt/mt.psgi"
6+ environment :
7+ MT_PID_FILE_PATH : ${MT_PID_FILE_PATH:-/tmp/mt.psgi.pid}
68 volumes :
79 - " ./plackup-mt:/usr/local/lib/mt/bin/plackup-mt"
10+ mt-watcher :
11+ build :
12+ context : mt-watcher
13+ working_dir : /var/www/cgi-bin/mt
14+ command : /usr/local/lib/mt/bin/mt-watcher.pl
15+ environment :
16+ PERL_FNS_NO_OPT : ${PERL_FNS_NO_OPT:-0}
17+ DISABLE_MT_WATCHER : ${DISABLE_MT_WATCHER:-0}
18+ volumes :
19+ - " ${MT_HOME_PATH:-../../movabletype}:/var/www/cgi-bin/mt"
20+ - " ./mt-watcher.pl:/usr/local/lib/mt/bin/mt-watcher.pl"
21+ - /var/run/docker.sock:/var/run/docker.sock
You can’t perform that action at this time.
0 commit comments