I have two commands to execute in release phase and as per this tutorial (https://devcenter.heroku.com/articles/release-phase), I have included them in a shell script named release.sh (located in the root of my Django project).
#!/bin/bash
python manage.py migrate
python manage.py compress
In my Procfile, I added the script thus, as described in the article.
release: ./release.sh
web: gunicorn myapp.wsgi --log-file -
But during release I get the following error.
/bin/sh: 1: ./release.sh: not found
Then the release fails.
I don't know if the problem is with the path in Procfile (I also tried bash $PWD/releash.sh
) or the file not being available at the time it is called. Any help would be appreciated.
EDIT:
My release.sh was in a subfolder and that's why it wasn't found, but now I'm getting permission denied.
/bin/sh: 1: ./release.sh: Permission denied
Running the App or bot on Heroku Now in order to turn on/execute our script, we have to open up our app on the Heroku Website, go to Resources, and hit edit on our worker. - Enable both the web and worker, then save. Note: It can take up to two minutes for the script to start running!
You can run multiple command inside Procfile using sh -c command : worker: sh -c 'firstCommand && secondCommand && etc...' Notes : Procfile should be at the project root level. A good answer will always include an explanation why this would solve the issue, so that the OP and any future readers can learn from it.
This worked
chmod u+x release.sh && ./release.sh
So Procfile becomes
release: chmod u+x release.sh && ./release.sh
web: gunicorn myapp.wsgi --log-file -
For this to work, release.sh
must be executable
Locally, you could run chmod a+x release.sh
. But you would not want to do that on heroku, so instead you can change the Profile to have this:
release: bash release.sh
web: gunicorn myapp.wsgi --log-file -
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With