Weather service installation
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,4 +5,3 @@
|
|||||||
configuration-production.yaml
|
configuration-production.yaml
|
||||||
|
|
||||||
.env
|
.env
|
||||||
run-docker.sh
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
weather_weather_api_base_url=https://api.openweathermap.org/data/2.5/weather
|
weather_weather_api_base_url=
|
||||||
weather_weather_api_key=4ce897f7ce77f84919fd990cc68d9d20
|
weather_weather_api_key=
|
||||||
weather_influx_db_base_url=http://192.168.1.44:8092
|
weather_influx_db_base_url=
|
||||||
weather_influx_db_token=R1BGVaxWrX_ySaovweRz6ZTBDvHa5omQkricJGmn3PrI44jpfU7411PSmHOCjGcNR7OcBjmtE9gA62boHHXoKg==
|
weather_influx_db_token=
|
||||||
weather_latitude=50.854019
|
weather_latitude=
|
||||||
weather_longitude=3.355230
|
weather_longitude=
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM rust:1.67 as builder
|
FROM rust:1.71 as builder
|
||||||
WORKDIR /usr/src/weather
|
WORKDIR /usr/src/weather
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN cargo install --path .
|
RUN cargo install --path .
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
docker build . -t weather-microservice:latest
|
|
||||||
docker tag weather-microservice:latest registry.willemserruys.com/weather-microservice:latest
|
|
||||||
docker push registry.willemserruys.com/weather-microservice:latest
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
file=/home/willem/repos/homeAutomation/microservices/weather/logs.$(date "+%F").txt
|
|
||||||
|
|
||||||
docker run --env RUST_LOG=info --env-file /home/willem/repos/homeAutomation/microservices/weather/.env registry.willemserruys.com/weather-microservice:latest &>> $file
|
|
||||||
3
microservices/weather/scripts/build-docker.sh
Executable file
3
microservices/weather/scripts/build-docker.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
docker build ../ -t weather-service:latest
|
||||||
21
microservices/weather/scripts/install.sh
Executable file
21
microservices/weather/scripts/install.sh
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
# This script should be run as root
|
||||||
|
# Build and install weather service
|
||||||
|
|
||||||
|
./build-docker.sh
|
||||||
|
|
||||||
|
ln -s $HOME/repos/homeAutomation/microservices/weather/run-docker.sh /usr/bin/weather-service
|
||||||
|
|
||||||
|
cp weather.service /etc/systemd/system/
|
||||||
|
cp weather.timer /etc/systemd/system/
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
||||||
|
systemctl enable weather.service
|
||||||
|
systemctl enable weather.timer
|
||||||
|
|
||||||
|
systemctl start weather.service
|
||||||
|
systemctl start weather.timer
|
||||||
|
|
||||||
|
|
||||||
3
microservices/weather/scripts/run-docker.sh
Executable file
3
microservices/weather/scripts/run-docker.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Make sure the weather-service-image exists locally (e.g. by running the build-docker script)
|
||||||
|
docker run --env RUST_LOG=info --env-file /home/pi/repos/homeAutomation/microservices/weather/.env.production weather-service:latest
|
||||||
8
microservices/weather/scripts/weather.service
Normal file
8
microservices/weather/scripts/weather.service
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Weather Service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/weather-service
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
8
microservices/weather/scripts/weather.timer
Normal file
8
microservices/weather/scripts/weather.timer
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Run weather service each 2 minutes
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=*:0/2
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
Reference in New Issue
Block a user