-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow to be run on a cron within the docker container #5
base: main
Are you sure you want to change the base?
Conversation
56aa85b
to
2424484
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Months later I am settled in after my move and can review this hahaha 😆
@@ -1,9 +1,11 @@ | |||
FROM python:3.11-alpine | |||
FROM python:3.11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not able to keep it on alpine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mm I can't remember the context here, but I think scheduling breaks when not on alpine?
@@ -18,8 +20,10 @@ RUN pdm install | |||
|
|||
# Add python source | |||
COPY venmo_auto_cashout /app/venmo_auto_cashout/ | |||
RUN pdm install | |||
RUN pdm install --production |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call 0389b38
venmo_auto_cashout/cli.py
Outdated
@@ -1,8 +1,8 @@ | |||
import sqlite3 | |||
import argparse | |||
from os import getenv | |||
from time import sleep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops c59f541
# output the date and time so when this is running on a cron we know the last time it was run | ||
output(f"Running venmo_auto_cashout at {datetime.now()}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's maybe add this to the script that runs via cron instead?
else | ||
# `-l` ensures that /etc/profile is picked up by the sh subshell | ||
# stdout redirect ensures logs are redirected to the parent process https://snippets.aktagon.com/snippets/945-how-to-get-cron-to-log-to-stdout-under-docker-and-kubernetes | ||
echo "${SCHEDULE} root sh -lc 'cd ${PWD} && $(which pdm) run venmo-auto-cashout' > /proc/1/fd/1 2>&1" >>/etc/crontab |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the /proc/1/fd/1
magic for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without this stdout of cron is not sent to the docker container's stdout
dockerStart.sh
Outdated
# debian slim does not include cron by default, this must be installed via Dockerfile | ||
# additionally, busybox does *not* add the cron process, so we must use the debian cron package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have this comment here? The dockerfile installs it so I don't think we need to include this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, removed
printenv | awk -F= '{print "export " "\""$1"\"""=""\""$2"\"" }' >>/etc/profile | ||
|
||
if [[ ${SCHEDULE} == "NONE" ]]; then | ||
pdm run venmo-auto-cashout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be
pdm run venmo-auto-cashout | |
exec pdm run venmo-auto-cashout |
and then we don't need the else
case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not following: why wouldn't we need the else case here? The else is for running this on a schedule.
9eaf8ac
to
3e1ff32
Compare
No description provided.