mirror of
https://github.com/derf/travelynx
synced 2024-11-10 06:54:17 +00:00
use 'maintenance' file to stop background jobs when running DB upgrades
This commit is contained in:
parent
0b725cbf66
commit
2d72ff8fc9
3 changed files with 19 additions and 0 deletions
|
@ -20,6 +20,10 @@ sub pull_sync {
|
||||||
my $request_count = 0;
|
my $request_count = 0;
|
||||||
for my $account_data ( $self->app->traewelling->get_pull_accounts ) {
|
for my $account_data ( $self->app->traewelling->get_pull_accounts ) {
|
||||||
|
|
||||||
|
if ( -e 'maintenance' ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
my $in_transit = $self->app->in_transit->get(
|
my $in_transit = $self->app->in_transit->get(
|
||||||
uid => $account_data->{user_id},
|
uid => $account_data->{user_id},
|
||||||
);
|
);
|
||||||
|
@ -84,6 +88,11 @@ sub push_sync {
|
||||||
my %push_result;
|
my %push_result;
|
||||||
|
|
||||||
for my $candidate ( $self->app->traewelling->get_pushable_accounts ) {
|
for my $candidate ( $self->app->traewelling->get_pushable_accounts ) {
|
||||||
|
|
||||||
|
if ( -e 'maintenance' ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$self->app->log->debug(
|
$self->app->log->debug(
|
||||||
"Pushing to Traewelling for UID $candidate->{uid}");
|
"Pushing to Traewelling for UID $candidate->{uid}");
|
||||||
my $trip_id = $candidate->{journey_data}{trip_id};
|
my $trip_id = $candidate->{journey_data}{trip_id};
|
||||||
|
@ -140,6 +149,10 @@ sub run {
|
||||||
|
|
||||||
my $trwl_pull_finished_at = DateTime->now( time_zone => 'Europe/Berlin' );
|
my $trwl_pull_finished_at = DateTime->now( time_zone => 'Europe/Berlin' );
|
||||||
|
|
||||||
|
if ( -e 'maintenance' ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
my $trwl_push_duration = $trwl_push_finished_at->epoch - $started_at->epoch;
|
my $trwl_push_duration = $trwl_push_finished_at->epoch - $started_at->epoch;
|
||||||
my $trwl_pull_duration
|
my $trwl_pull_duration
|
||||||
= $trwl_pull_finished_at->epoch - $trwl_push_finished_at->epoch;
|
= $trwl_pull_finished_at->epoch - $trwl_push_finished_at->epoch;
|
||||||
|
|
|
@ -32,6 +32,10 @@ sub run {
|
||||||
|
|
||||||
for my $entry ( $self->app->in_transit->get_all_active ) {
|
for my $entry ( $self->app->in_transit->get_all_active ) {
|
||||||
|
|
||||||
|
if ( -e 'maintenance' ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
my $uid = $entry->{user_id};
|
my $uid = $entry->{user_id};
|
||||||
my $dep = $entry->{dep_eva};
|
my $dep = $entry->{dep_eva};
|
||||||
my $arr = $entry->{arr_eva};
|
my $arr = $entry->{arr_eva};
|
||||||
|
|
|
@ -12,9 +12,11 @@ if [ "$1" = "with-deps" ]; then
|
||||||
carton install
|
carton install
|
||||||
cd ..
|
cd ..
|
||||||
sudo systemctl stop travelynx
|
sudo systemctl stop travelynx
|
||||||
|
touch maintenance
|
||||||
mv local local.old
|
mv local local.old
|
||||||
mv local.new/local .
|
mv local.new/local .
|
||||||
perl index.pl database migrate
|
perl index.pl database migrate
|
||||||
|
rm -f maintenance
|
||||||
sudo systemctl start travelynx
|
sudo systemctl start travelynx
|
||||||
elif perl index.pl database has-current-schema; then
|
elif perl index.pl database has-current-schema; then
|
||||||
sudo systemctl reload travelynx
|
sudo systemctl reload travelynx
|
||||||
|
|
Loading…
Reference in a new issue