Skip to content
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

Running on Google Cloud Run (but how to cron?) #3517

Open
VoordeMensen opened this issue Jan 26, 2020 · 3 comments
Open

Running on Google Cloud Run (but how to cron?) #3517

VoordeMensen opened this issue Jan 26, 2020 · 3 comments

Comments

@VoordeMensen
Copy link

I got Monica to run on the new (stateless) Google Cloud Run - which is almost free for personal use.

  1. I needed to connect to an external MySQL-server (ie: Google Cloud SQL, through a unix socket in .env) because Google Run only supports stateless HTTP
  2. I had to disable the "waitfordb" function in entrypoint.sh - because it checks if mysql is running on port 3306 inside the Docker and Google Run doesn't support that.

The only thing is that it, being stateless, doesn't support cron so my mail etc. jobs don't run. How can I get my scheduled tasks to run? Any suggestions?

@djaiss
Copy link
Member

djaiss commented Feb 1, 2020

Ok so technically you could add a new route (in web.php) that would trigger the cron when it’s accessed. That would work. But it requires actual work.

@rmchale
Copy link

rmchale commented Oct 2, 2021

I am interested in this as well. Do you have a diff with your changes?

@VoordeMensen
Copy link
Author

No not really but my .env.prod looks something like this:

DB_UNIX_SOCKET=/cloudsql/#######:europe-west2:monica
DB_DATABASE=monica
DB_USERNAME=#######
DB_PASSWORD=#############

And in entrypoint.sh I commented out line 48:

    # Run migrations
    # waitfordb
    ${ARTISAN} monica:update --force -vv

    if [ -n "${SENTRY_SUPPORT:-}" -a "$SENTRY_SUPPORT" = "true" -a -z "${SENTRY_NORELEASE:-}" -a -n "${SENTRY_ENV:-}" ]; then
        commit=$(cat .sentry-commit)
        release=$(cat .sentry-release)
        ${ARTISAN} sentry:release --release="$release" --commit="$commit" --environment="$SENTRY_ENV" -v || true
    fi

    if [ ! -f "${STORAGE}/oauth-public.key" -o ! -f "${STORAGE}/oauth-private.key" ]; then
        echo "Passport keys creation ..."
        ${ARTISAN} passport:keys
        ${ARTISAN} passport:client --personal --no-interaction
        echo "! Please be careful to backup /var/www/monica/storage/oauth-public.key and /var/www/monica/storage/oauth-private.key files !"
    fi

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants