Skip to content

Commit

Permalink
Add cron etc scripts from prod to the repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Deraen committed Oct 25, 2024
1 parent ffb1d30 commit ad59abc
Show file tree
Hide file tree
Showing 13 changed files with 262 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
!/osrm/update-data.sh
.calva

random-files/

!webapp/dev/repl.clj
webapp/.nrepl-port
webapp/*.log
webapp/target
webapp/*-init.clj
webapp/resources/public/js/compiled
webapp/resources/public/google*.html
webapp/.cljs_rhino_repl
webapp/.lein-env
webapp/.lein-failures
Expand Down
12 changes: 12 additions & 0 deletions scripts/deploy-backend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

cd /var/lipas
source .env.sh

docker compose run --rm backend-build
docker compose run --rm backend-migrate
docker compose stop backend
docker compose up -d backend
# /usr/local/bin/docker-compose restart proxy
10 changes: 10 additions & 0 deletions scripts/deploy-frontend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

/cd /var/lipas
source .env.sh

docker compose run --rm frontend-npm-deps
docker compose run --rm frontend-npm-bundle
docker compose run --rm frontend-build
15 changes: 15 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

cd /var/lipas
source .env.sh

docker compose run --rm backend-build
docker compose run --rm backend-migrate
docker compose stop backend
docker compose up -d backend
docker compose run --rm frontend-npm-deps
docker compose run --rm frontend-npm-bundle
docker compose run --rm frontend-build
docker compose restart proxy
10 changes: 10 additions & 0 deletions scripts/index.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

cd /var/lipas
source .env.sh
docker compose run backend-index-search
docker compose run backend-index-search --analytics

echo TADA!
9 changes: 9 additions & 0 deletions scripts/purge-mapproxy-cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

# Meant to be run from cron

cd /var/lipas
source .env.sh
docker compose exec mapproxy /lipas/purge.sh
7 changes: 7 additions & 0 deletions scripts/refresh-mat-views.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -e

cd /var/lipas
source .env.sh
cat /var/lipas/scripts/refresh-mat-views.sql | /usr/bin/docker compose exec -T postgres psql -U postgres -d "lipas-legacy"
149 changes: 149 additions & 0 deletions scripts/refresh-mat-views.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
REFRESH MATERIALIZED VIEW types.lipas_1510_tekojaakentta;
REFRESH MATERIALIZED VIEW types.lipas_1520_luistelukentta;
REFRESH MATERIALIZED VIEW types.lipas_1530_kaukalo;
REFRESH MATERIALIZED VIEW types.lipas_111_kansallispuisto;
REFRESH MATERIALIZED VIEW types.lipas_1540_pikaluistelurata;
REFRESH MATERIALIZED VIEW types.lipas_107_matkailupalveluiden_alue;
REFRESH MATERIALIZED VIEW types.lipas_1120_lahiliikuntapaikka;
REFRESH MATERIALIZED VIEW types.lipas_1550_luistelureitti;
REFRESH MATERIALIZED VIEW types.lipas_108_virkistysmetsa;
REFRESH MATERIALIZED VIEW types.lipas_1560_alamakiluistelurata;
REFRESH MATERIALIZED VIEW types.lipas_112_muu_luonnonsuojelualue;
REFRESH MATERIALIZED VIEW types.lipas_1610_golfin_harjoitusalue;
REFRESH MATERIALIZED VIEW types.lipas_109_valtion_retkeilyalue;
REFRESH MATERIALIZED VIEW types.lipas_110_eramaa_alue;
REFRESH MATERIALIZED VIEW types.lipas_1110_liikuntapuisto;
REFRESH MATERIALIZED VIEW types.lipas_1320_lentopallokentta;
REFRESH MATERIALIZED VIEW types.lipas_1620_golfkentta;
REFRESH MATERIALIZED VIEW types.lipas_1330_beachvolleykentta;
REFRESH MATERIALIZED VIEW types.lipas_1310_koripallokentta;
REFRESH MATERIALIZED VIEW types.lipas_1340_pallokentta;
REFRESH MATERIALIZED VIEW types.lipas_1350_jalkapallostadion;
REFRESH MATERIALIZED VIEW types.lipas_1180_frisbeegolf_rata;
REFRESH MATERIALIZED VIEW types.lipas_1360_pesapallostadion;
REFRESH MATERIALIZED VIEW types.lipas_1370_tenniskentta_alue;
REFRESH MATERIALIZED VIEW types.lipas_1630_golfin_harjoitushalli;
REFRESH MATERIALIZED VIEW types.lipas_1210_yleisurheilun_harjoitusalue;
REFRESH MATERIALIZED VIEW types.lipas_1130_ulkokuntoilupaikka;
REFRESH MATERIALIZED VIEW types.lipas_1220_yleisurheilukentta;
REFRESH MATERIALIZED VIEW types.lipas_1380_rullakiekkokentta;
REFRESH MATERIALIZED VIEW types.lipas_2230_jalkapallohalli;
REFRESH MATERIALIZED VIEW types.lipas_2240_saliandyhalli;
REFRESH MATERIALIZED VIEW types.lipas_2250_skeittihalli;
REFRESH MATERIALIZED VIEW types.lipas_2260_sulkapallohalli;
REFRESH MATERIALIZED VIEW types.lipas_2270_squash_halli;
REFRESH MATERIALIZED VIEW types.lipas_2530_pikaluisteluhalli;
REFRESH MATERIALIZED VIEW types.lipas_2610_keilahalli;
REFRESH MATERIALIZED VIEW types.lipas_301_laavu_kota_kammi;
REFRESH MATERIALIZED VIEW types.lipas_2310_yksittainen_yleisurheilun_suorituspaikka;
REFRESH MATERIALIZED VIEW types.lipas_3220_uimaranta;
REFRESH MATERIALIZED VIEW types.lipas_4220_hiihtotunneli;
REFRESH MATERIALIZED VIEW types.lipas_3230_uimapaikka;
REFRESH MATERIALIZED VIEW types.lipas_4230_lumilautatunneli;
REFRESH MATERIALIZED VIEW types.lipas_4240_lasketteluhalli;
REFRESH MATERIALIZED VIEW types.lipas_4310_harjoitushyppyrimaki;
REFRESH MATERIALIZED VIEW types.lipas_3110_uimahalli;
REFRESH MATERIALIZED VIEW types.lipas_3240_talviuintipaikka;
REFRESH MATERIALIZED VIEW types.lipas_4110_laskettelun_suorituspaikat;
REFRESH MATERIALIZED VIEW types.lipas_4210_curlingrata;
REFRESH MATERIALIZED VIEW types.lipas_4402_latu;
REFRESH MATERIALIZED VIEW types.lipas_4403_kavelyreitti;
REFRESH MATERIALIZED VIEW types.lipas_4430_hevosreitti;
REFRESH MATERIALIZED VIEW types.lipas_4404_luontopolku;
REFRESH MATERIALIZED VIEW types.lipas_4411_maastopyorailyreitti;
REFRESH MATERIALIZED VIEW types.lipas_4440_koirahiihtolatu;
REFRESH MATERIALIZED VIEW types.lipas_4451_melontareitti;
REFRESH MATERIALIZED VIEW types.lipas_1640_ratagolf;
REFRESH MATERIALIZED VIEW types.lipas_4412_pyorailyreitti;
REFRESH MATERIALIZED VIEW types.lipas_4405_retkeilyreitti;
REFRESH MATERIALIZED VIEW types.lipas_4452_vesiretkeilyreitti;
REFRESH MATERIALIZED VIEW types.lipas_4421_moottorikelkkareitti;
REFRESH MATERIALIZED VIEW types.lipas_4422_moottorikelkkaura;
REFRESH MATERIALIZED VIEW types.lipas_4510_suunnistusalue;
REFRESH MATERIALIZED VIEW types.lipas_4630_kilpahiihtokeskus;
REFRESH MATERIALIZED VIEW types.lipas_4620_ampumahiihtokeskus;
REFRESH MATERIALIZED VIEW types.lipas_4830_jousiammuntarata;
REFRESH MATERIALIZED VIEW types.lipas_4710_ulkokiipeilyseina;
REFRESH MATERIALIZED VIEW types.lipas_4720_kiipeilykallio;
REFRESH MATERIALIZED VIEW types.lipas_4840_jousiammuntamaastorata;
REFRESH MATERIALIZED VIEW types.lipas_5110_soutustadion;
REFRESH MATERIALIZED VIEW types.lipas_4640_hiihtomaa;
REFRESH MATERIALIZED VIEW types.lipas_5120_purjehdusalue;
REFRESH MATERIALIZED VIEW types.lipas_4810_ampumarata;
REFRESH MATERIALIZED VIEW types.lipas_4820_ampumaurheilukeskus;
REFRESH MATERIALIZED VIEW types.lipas_5130_moottirveneurheilualue;
REFRESH MATERIALIZED VIEW types.lipas_5160_soudun_ja_melonnan_sisaharjoittelutila;
REFRESH MATERIALIZED VIEW types.lipas_5210_urheiluilmailualue;
REFRESH MATERIALIZED VIEW types.lipas_5370_jaaspeedway_rata;
REFRESH MATERIALIZED VIEW types.lipas_5310_moottoriurheilukeskus;
REFRESH MATERIALIZED VIEW types.lipas_5330_moottorirata;
REFRESH MATERIALIZED VIEW types.lipas_6110_ratsastuskentta;
REFRESH MATERIALIZED VIEW types.lipas_6120_ratsastusmaneesi;
REFRESH MATERIALIZED VIEW types.lipas_5340_karting_rata;
REFRESH MATERIALIZED VIEW types.lipas_5140_vesihiihtoalue;
REFRESH MATERIALIZED VIEW types.lipas_5320_moottoripyorailualue;
REFRESH MATERIALIZED VIEW types.lipas_6130_esteratsastuskentta;
REFRESH MATERIALIZED VIEW types.lipas_5350_kiihdytysrata;
REFRESH MATERIALIZED VIEW types.lipas_5360_jokamies_ja_rallicross_rata;
REFRESH MATERIALIZED VIEW types.lipas_6140_ravirata;
REFRESH MATERIALIZED VIEW types.lipas_7000_huoltorakennukset;
REFRESH MATERIALIZED VIEW types.lipas_201_kalastusalue;
REFRESH MATERIALIZED VIEW types.lipas_202_telttailu_ja_leiriytyminen;
REFRESH MATERIALIZED VIEW types.lipas_203_veneilyn_palvelupaikka;
REFRESH MATERIALIZED VIEW types.lipas_204_luontotorni;
REFRESH MATERIALIZED VIEW types.lipas_205_rantautumispaikka;
REFRESH MATERIALIZED VIEW types.lipas_206_ruoanlaittopaikka;
REFRESH MATERIALIZED VIEW types.lipas_207_opastuspiste;
REFRESH MATERIALIZED VIEW types.lipas_2110_kuntokeskus;
REFRESH MATERIALIZED VIEW types.lipas_2120_kuntosali;
REFRESH MATERIALIZED VIEW types.lipas_2130_voimailusali;
REFRESH MATERIALIZED VIEW types.lipas_2140_kamppailulajien_sali;
REFRESH MATERIALIZED VIEW types.lipas_2150_liikuntasali;
REFRESH MATERIALIZED VIEW types.lipas_2210_liikuntahalli;
REFRESH MATERIALIZED VIEW types.lipas_101_lahipuisto;
REFRESH MATERIALIZED VIEW types.lipas_102_ulkoilupuisto;
REFRESH MATERIALIZED VIEW types.lipas_2220_monitoimihalli;
REFRESH MATERIALIZED VIEW types.lipas_103_ulkoilualue;
REFRESH MATERIALIZED VIEW types.lipas_104_retkeilyalue;
REFRESH MATERIALIZED VIEW types.lipas_2280_tennishalli;
REFRESH MATERIALIZED VIEW types.lipas_106_monikayttoalue;
REFRESH MATERIALIZED VIEW types.lipas_2290_petanque_halli;
REFRESH MATERIALIZED VIEW types.lipas_1140_parkouralue;
REFRESH MATERIALIZED VIEW types.lipas_1150_skeitti_rullaluistelupaikka;
REFRESH MATERIALIZED VIEW types.lipas_1160_pyorailualue;
REFRESH MATERIALIZED VIEW types.lipas_2320_telinevoimistelutila;
REFRESH MATERIALIZED VIEW types.lipas_1170_pyorailurata;
REFRESH MATERIALIZED VIEW types.lipas_2330_poytatennistila;
REFRESH MATERIALIZED VIEW types.lipas_2340_miekkailutila;
REFRESH MATERIALIZED VIEW types.lipas_2350_tanssitila;
REFRESH MATERIALIZED VIEW types.lipas_2360_sisa_ampumarata;
REFRESH MATERIALIZED VIEW types.lipas_2370_sisakiipeilyseina;
REFRESH MATERIALIZED VIEW types.lipas_2380_parkour_sali;
REFRESH MATERIALIZED VIEW types.lipas_2510_harjoitusjaahalli;
REFRESH MATERIALIZED VIEW types.lipas_2520_kilpajaahalli;
REFRESH MATERIALIZED VIEW types.lipas_302_tupa;
REFRESH MATERIALIZED VIEW types.lipas_304_ulkoilumaja_hiihtomaja;
REFRESH MATERIALIZED VIEW types.lipas_3120_uima_allas;
REFRESH MATERIALIZED VIEW types.lipas_3130_kylpyla;
REFRESH MATERIALIZED VIEW types.lipas_3210_maauimala;
REFRESH MATERIALIZED VIEW types.lipas_4320_hyppyrimaki;
REFRESH MATERIALIZED VIEW types.lipas_4401_kuntorata;
REFRESH MATERIALIZED VIEW types.lipas_4610_ampumahiihdon_harjoittelualue;
REFRESH MATERIALIZED VIEW types.lipas_4520_hiihtosuunnistusalue;
REFRESH MATERIALIZED VIEW types.lipas_4530_pyorasuunnistusalue;
REFRESH MATERIALIZED VIEW types.lipas_5150_koskimelontakeskus;
REFRESH MATERIALIZED VIEW types.lipas_6210_koiraurheilualue;
REFRESH MATERIALIZED VIEW types.lipas_6220_koiraurheiluhalli;
REFRESH MATERIALIZED VIEW types.lipas_4401_kuntorata_3d;
REFRESH MATERIALIZED VIEW types.lipas_4402_latu_3d;
REFRESH MATERIALIZED VIEW types.lipas_4403_kavelyreitti_3d;
REFRESH MATERIALIZED VIEW types.lipas_4404_luontopolku_3d;
REFRESH MATERIALIZED VIEW types.lipas_4405_retkeilyreitti_3d;
REFRESH MATERIALIZED VIEW types.lipas_4411_maastopyorailyreitti_3d;
REFRESH MATERIALIZED VIEW types.lipas_4412_pyorailyreitti_3d;
REFRESH MATERIALIZED VIEW types.lipas_4421_moottorikelkkareitti_3d;
REFRESH MATERIALIZED VIEW types.lipas_4422_moottorikelkkaura_3d;
REFRESH MATERIALIZED VIEW types.lipas_4430_hevosreitti_3d;
REFRESH MATERIALIZED VIEW types.lipas_4440_koirahiihtolatu_3d;
REFRESH MATERIALIZED VIEW types.lipas_4451_melontareitti_3d;
REFRESH MATERIALIZED VIEW types.lipas_4452_vesiretkeilyreitti_3d;
9 changes: 9 additions & 0 deletions scripts/reindex-legacy-api.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

# Meant to be run from cron

cd /var/lipas
source .env.sh
docker compose run --rm legacy-api-worker
9 changes: 9 additions & 0 deletions scripts/reindex.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

# Meant to be run from cron

cd /var/lipas
source .env.sh
docker compose run --rm backend-index-search --analytics
9 changes: 9 additions & 0 deletions scripts/restart-geoserver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

# Meant to be run from cron

cd /var/lipas
source .env.sh
docker compose restart geoserver
18 changes: 18 additions & 0 deletions scripts/start-services.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -e

cd /var/lipas
source .env.sh

# Force recreate of mapproxy image (kludge)
docker compose rm -f mapproxy

# Start backend services
docker compose up -d backend mapproxy logstash kibana legacy-api geoserver worker integrations

# Wait until critical services are ready to accept connections
timeout 120 bash -c 'until echo > /dev/tcp/localhost/8091; do sleep 0.5; done'

# Start frontend proxy
docker compose up -d proxy
4 changes: 2 additions & 2 deletions webapp/src/clj/lipas/migrate_data.clj
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,6 @@
(def search (:search system))
(def user (core/get-user db "import@lipas.fi"))
(-main "--old-lipas-since" "2019-01-01T00:00:00.000Z")
(-main "--city-data" "/Users/vaotjuha/lipas/raportit/city_stats5.edn")
(-main "--city-data" "/var/lipas/lipas/random-files/city_stats5.edn")
(-main "--old-lipas" "527986")
(-main "--old-lipas-edn" "/Users/vaotjuha/lipas/data_migration/missing-ids.edn"))
(-main "--old-lipas-edn" "/var/lipas/random-files/missing-ids.edn"))

0 comments on commit ad59abc

Please sign in to comment.