summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2024-06-12 21:53:35 +0200
committerBirte Kristina Friesel <derf@finalrewind.org>2024-06-12 21:53:35 +0200
commit2d72ff8fc9dc0980a75cd427ad11a2c1d3ea3c73 (patch)
treef9cec0da5ac910126d2667b55ec0414cb56e55a1
parent0b725cbf6649608e6b29e38f9eb081fc8a37257a (diff)
use 'maintenance' file to stop background jobs when running DB upgrades
-rw-r--r--lib/Travelynx/Command/traewelling.pm13
-rw-r--r--lib/Travelynx/Command/work.pm4
-rwxr-xr-xupdate.sh2
3 files changed, 19 insertions, 0 deletions
diff --git a/lib/Travelynx/Command/traewelling.pm b/lib/Travelynx/Command/traewelling.pm
index 8f62c2b..772c63c 100644
--- a/lib/Travelynx/Command/traewelling.pm
+++ b/lib/Travelynx/Command/traewelling.pm
@@ -20,6 +20,10 @@ sub pull_sync {
my $request_count = 0;
for my $account_data ( $self->app->traewelling->get_pull_accounts ) {
+ if ( -e 'maintenance' ) {
+ return;
+ }
+
my $in_transit = $self->app->in_transit->get(
uid => $account_data->{user_id},
);
@@ -84,6 +88,11 @@ sub push_sync {
my %push_result;
for my $candidate ( $self->app->traewelling->get_pushable_accounts ) {
+
+ if ( -e 'maintenance' ) {
+ return;
+ }
+
$self->app->log->debug(
"Pushing to Traewelling for UID $candidate->{uid}");
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' );
+ if ( -e 'maintenance' ) {
+ return;
+ }
+
my $trwl_push_duration = $trwl_push_finished_at->epoch - $started_at->epoch;
my $trwl_pull_duration
= $trwl_pull_finished_at->epoch - $trwl_push_finished_at->epoch;
diff --git a/lib/Travelynx/Command/work.pm b/lib/Travelynx/Command/work.pm
index 8ae918e..c9ac9b7 100644
--- a/lib/Travelynx/Command/work.pm
+++ b/lib/Travelynx/Command/work.pm
@@ -32,6 +32,10 @@ sub run {
for my $entry ( $self->app->in_transit->get_all_active ) {
+ if ( -e 'maintenance' ) {
+ return;
+ }
+
my $uid = $entry->{user_id};
my $dep = $entry->{dep_eva};
my $arr = $entry->{arr_eva};
diff --git a/update.sh b/update.sh
index d78f8a5..58e3663 100755
--- a/update.sh
+++ b/update.sh
@@ -12,9 +12,11 @@ if [ "$1" = "with-deps" ]; then
carton install
cd ..
sudo systemctl stop travelynx
+ touch maintenance
mv local local.old
mv local.new/local .
perl index.pl database migrate
+ rm -f maintenance
sudo systemctl start travelynx
elif perl index.pl database has-current-schema; then
sudo systemctl reload travelynx