i am trying run frontend and backend apps on one server on Heroku.
web: gunicorn app.app_back:app
web: gunicorn app.app:app
But this example execute only the last app. Can i run several apps on Heroku? And do it without Nginx.
Related
My Procfile - web: gunicorn main:server
how i started my project :
git commit -m "Demo"
git push heroku main
heroku ps:scale web=1
`app = dash.Dash(name, external_stylesheets=[dbc.themes.BOOTSTRAP],
meta_tags=[{'name': 'viewport',
'content': 'width=device-width, initial-scale=1.0'}]
)
server = app.server
some code
if name == 'main':
app.run_server(debug=True)`
this works on heroku but doesn't work on server in docker container
what do i need to write in dockerfile and how to run it?
I tried to write a dockerfile myself, but when I ran it, it immediately stopped
So, I have a Django Project which has a background task for a method to run.
I made following adjustments to procfile
Initially
web: python manage.py collectstatic --no-input; gunicorn project.wsgi --log-file - --log-level debug
Now
web: python manage.py collectstatic --no-input; gunicorn project.wsgi --log-file - --log-level debug
worker: python manage.py process_tasks
Inspite of adding worker, when I deploy my project on heroku it does not run the background task. The background task gets created and can be seen registered in django admin but does not run. I hoped after reading various articles (one of them being https://medium.com/#201651034/background-tasks-in-django-and-heroku-58ac91bc881c) adding worker: python mnanage.py process_tasks would do the job but it didn't.
If I execute in my heroku cli: heroku run python manage.py process_tasks it only runs on the data which was initially present in database and not on any new data that I add after deployment.
Note: python manage.py process_tasks is what I use to get the background task to run on my local server.
So, if anyone could help me in running the background task after deployment on heroku.
Your Procfile seems right, you need to scale your worker dyno using heroku scale worker=1 from heroku CLI or you can also scale your worker dyno from heroku dashboard.
For scaling worker dyno through browser:-
Visit https://dashboard.heroku.com/apps/<your-app-name>/resources
Edit your worker dyno and scale it from there confirm your changes
In CLI use command heroku logs -t -p worker to see status and logs for worker dyno
I am trying to deploy a flask app I made to Heroku with success.
The app is generated but I get errors when I push the code to the Heroku repository.
My flask app is inside a module called server.py and the variable is named app.
At first I tried using gunicorn and writing
web: gunicorn server:app
and deplying but no web dynos were up and I get an error stating it is the Procfile file.
Red about it about and saw that Gunicorn is not really working on windows so I tried installing Waitress and deploying without success. this time my profcile was written as all of these (tried several times):
web: waitress-serve --listen=*:8000 server.wsgi:application
web: waitress-serve --listen=*:8000 app.wsgi:application
And so on.
to add a web dyno I should scale it because heroku ps: showes that there is no dynos.
When I try to run heroku ps:scale web=1 I get:
Scaling dynos... !
â–¸ Couldn't find that process type.
What am i doing wrong?
I was having the same problem. Particularly, waitress works locally in Windows (inside a Procfile.windows file web: waitress-serve index:server, then with heroku CLI heroku local -f Procfile.windows), but failed after Heroku deployment. Workaround for me was to locally test with waitress (like explained), but deploy with gunicorn (web: gunicorn index:server inside Procfile). Let me know if this works for you.
I am having trouble running my django app on Heroku. Following is my file structures:
---django_blog
---media_cdn
---static_cdn
---Procfile
---requirements.txt
---runtime.txt
---src
---blog
---...
---settings.py
---manage.py
---...
So 'src' is actually is my project root, and 'blog' is my app. I tried made the procfile to be
web: blog.wsgi --log-file -
and
web: src.blog.wsgi --log-file -
But none of them works. When I checked the heroku logs file, I found this error:
ImportError: No module named 'blog'
From Heroku documentation:
First, and most importantly, Heroku web applications require a
Procfile.
This file (named Procfile) is used to explicitly declare your
application’s process types and entry points. It is located in the
root of your repository.
You need to be more specific about how you declare your process types, if you are using gunicorn for this you will declare --chdir because you want to run it from different folder:
web: gunicorn --chdir src myproject.wsgi --log-file -
On the other hand I'm not using gunicorn rather I declare it like this:
web: python myproject/manage.py runserver 0.0.0.0:$PORT --noreload
FYI - Switch to gunicorn in production!
Here is my project file
Procfile
web: python main.py
requirement.txt
webapp2==2.3
main.py
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write("hello")
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
still heroku give out a Application Error
what's wrong with my project?
Base on their getting started with python it seems like you need gunicorn web server. Try adding gunicorn in your requirements.txt and procfile web: gunicorn main:app
Forgot to add the link:
https://devcenter.heroku.com/articles/python
Also here is my webapp2-starter, it's setup to act like an appengine dev server but works outside app engine.
https://github.com/faisalraja/webapp2-starter