Skip to content

Commit

Permalink
fixed cron job not running
Browse files Browse the repository at this point in the history
  • Loading branch information
FrenchGithubUser committed Jan 27, 2025
1 parent 282bcdf commit ab3d9ef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ COPY init.sh /init.sh
RUN chmod +x /init.sh

# Collect data every 6 hours
RUN echo "0 */6 * * * /cron.sh" > /etc/cron.d/cron
ADD crontab /etc/cron.d/cron
RUN chmod 0644 /etc/cron.d/cron
RUN touch /var/log/cron.log

# backend
EXPOSE 1323
Expand All @@ -54,7 +56,7 @@ EXPOSE 80
ENTRYPOINT ["/usr/bin/tini", "--"]

CMD ["sh", "-c", "\
service cron start && \
cron && \
cd backend && ./backend & \
nginx -g 'daemon off;' & \
cd / && /init.sh && \
Expand Down
4 changes: 3 additions & 1 deletion cron.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash

source /etc/environment

if [[ -z "${API_KEY}" ]]; then
echo "Error: API_KEY environment variable is not set."
exit 1
fi

curl -X GET http://localhost:1323/update \
curl -X GET http://localhost:1323/api/update \
-H "X-API-Key: ${API_KEY}"
2 changes: 2 additions & 0 deletions crontab
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0 */6 * * * root /cron.sh >> /var/log/cron.log 2>&1
# Don't remove the empty line at the end of this file. It is required to run the cron job
5 changes: 3 additions & 2 deletions init.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/bin/bash

# used for the cron job
printenv >> /etc/environment &

database_path="/backend/config/database.db"
config_json_path="/backend/config/config.json"
config_sample_json_path="/backend/config_sample/config_sample.json"




if [ -e "$config_json_path" ]; then
# todo: add newly supported indexers if needed
echo "Config file already exists, skipping copy"
Expand Down

0 comments on commit ab3d9ef

Please sign in to comment.