Pregunta

I have a cronjob running in Openshift which was fine until some days ago, now all of a sudden it stopped working. This is the script: fetch_feeds

. /usr/bin/rhcsh
pushd ${OPENSHIFT_REPO_DIR} > /dev/null
bundle exec rake fetch_feeds RACK_ENV="production"
popd > /dev/null

Execute bit is set. It worked the whole time, I did not push updates to the app. I can login via ssh and execute it manually

cd app-root/repo/.openshift/cron/hourly/
sh ./fetch_feeds

Logs say

/var/lib/openshift/xxxxxx/app-root/runtime/repo//.openshift/cron/hourly/fetch_feeds: line 3: bundle: No such file or directory

but if I cd into the directory and execute bundle it works. Force-stopping and starting the app did not work. I don't want to recreate the app because I will lose some settings. Any idea what else I can do? Thanks!

EDIT: Deleting and re-adding the cron-cartridge did not change anything.

EDIT2: Rebuild the application from scratch with the same instructions, it works. Seems like some update to the Openshift Platform borked something in my app. I still would like to know what happened but I don't know where to look at.

¿Fue útil?

Solución

The error in the logs seem to be saying that the bundle command cannot be found. Meaning the bundler gem is not installed or something.

It should be related to this question in SO. You can follow the link within to the OpenShift Bug Report.

The problem is that with the previous OpenShift update, the Ruby 1.9 cartridge is supposed to be using Ruby 1.9.3 but it somehow got changed to Ruby 1.8 instead. Thus, many of the gems installed with Ruby 1.9 will not be found when it is using Ruby 1.8. The workaround is to export the PATH and LD_LIBRARY_PATH in the cron script (refer to the bug report).

Noticed you tried again so the bugfix might have been pushed out to OpenShift already. Not too sure about that.

Nice to see a fellow stringer user here. :)

Otros consejos

These are some commands I needed to run for my papertrailapp cartridge, you might need to do something similar

https://github.com/openshift-cartridges/openshift-papertrailapp-cartridge/blob/master/bin/setup

#!/bin/bash -eu

export PATH=/opt/rh/ruby193/root/bin:$PATH
export LD_LIBRARY_PATH=/opt/rh/ruby193/root/usr/lib64
mkdir $OPENSHIFT_PAPERTRAILAPP_DIR/logs
cd $OPENSHIFT_PAPERTRAILAPP_DIR && bundle install

Have you checked the security context?

ps -Z to see what the context is for your process then check the permissions on the directory ls -Z to make sure the context is appropriate.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top