Yowsup working on normal EC2 instance but not on Heroku - django

I have developed a micro-service in django to access the yowsup2 library for whatsapp.
Everything works fine on my local environment with the procfile configured correctly.
web: gunicorn XXXXX.wsgi --workers=1
After I configured it on heroku.
heroku local
also works correctly.
But when I pushed the code to heroku server.
The initialisation code for yowsup gets stuck on
storing prekeys 100%
After spending 4 hours I were not able to make it work on heroku.
So switched back to Amazon EC2 Instance and its working like charm on that.
Software stack:
Django
Gunicorn
yowsup2
Django Rest Framework
Any help on this would be appreciated.

Related

What is the best way to develop an Elastic Beanstalk Django application locally?

I have recently deployed my Django application on Elastic Beanstalk.
I have everything working now, but I'm curious what the best way to develop locally is.
Currently, after I make a change locally, I have to commit the changes via git and then run eb deploy. This process takes 1-3 minutes which is not ideal for making changes.
The Django application will not run on my local machine, as it is configured for EB.
You are right, having to deploy remotely during development isn't best practice.
Have you considered Docker?
To run a typical Django app locally using Docker, you'll need to dockerize:
The Django app
Database eg Postgres
Worker eg Celery
Local mailer eg Mailhog
Not a very long list.
Obviously you'll add or remove from that list depending on how complex or simple your app is.

How to set virtualenv to stay active on a host server

I created a website that uses vuejs as the frontend and django as the backend with another service running behind everything that im making api calls to.
So django is setup in a way to look at the dist folder of Vuejs and serve it if you run manage.py runserver. but the problem is that my service that I created is
is also in python and it needs to run in a virtualenv in order to work (It uses tensorflow 1.15.2 and this can only run in a contained environment)
I'm sitting here and wondering how I can deploy the django application and keep the virtualenv active and Im coming up with nothing, I've tried doing some research on this but everything I found was not relevant to my problem. I've deployed it and when I close the ssh connection the virtualenv stops.
If there is anyone that can enlighten my ways I would appreciate it.
i think you need to nginx: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
if you are search for keep states just in terminal i suggest tmux https://github.com/tmux/tmux/wiki
You can use uWSGI and nginx to deploy Django apps on server. Here's helpful articles:
https://www.digitalocean.com/community/tutorials/how-to-set-up-uwsgi-and-nginx-to-serve-python-apps-on-centos-7
https://www.digitalocean.com/community/tutorials/how-to-set-up-uwsgi-and-nginx-to-serve-python-apps-on-centos-7
Django official docs also has a page about it: https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/uwsgi/
There are articles from developers so you can refer them in case you get stuck anywhere:
https://www.freecodecamp.org/news/django-uwsgi-nginx-postgresql-setup-on-aws-ec2-ubuntu16-04-with-python-3-6-6c58698ae9d3/
https://medium.com/#biswashirok/deploying-django-python-3-6-to-digital-ocean-with-uwsgi-nginx-ubuntu-18-04-3f8c2731ade1

After deploying django in AWS EB its not working similarly as it runs in localhost

This is how Admin page works in local host
This is how its showing after deploying in AWS EB
can i get help on this like how to get it normal or how to modify it using my own templates please .
In development django itself serves the files, which is not scalable in production, and thus requires you to collect your static files as documented here and serve them using your proxy server.
You can read about how collect static files in django on Elasticbeanstalk here
Before deploying run : python manage.py collectstatic
After running this you should deploy again like you usually do.

What are the localhost URLs for OpenShift hosted Django apps

I created a Django application locally and then using the django openshift template from
here I uploaded it to OpenShift successfully. Now I'm trying to work on the local repository for adding additional features but when I run the server locally, I get a bad url error.
What I would like to know is how do I locally host a OpenShift Django App?
I also tried rhc tail -a appname but that only gets me a small amount of debug info If I can't locally host it then is there a way with which I can see the python print() output for the app hosted on OpenShift?

Does uWSGI need to be restarted when Django code changes?

I'm working on a Django webapp that's running under nginx and uWSGI. When I deploy new Django code (e.g., settings.py), do I need to restart uWSGI? If so, why?
Background: I had a scenario where I updated settings.py and some other code and deployed it. I did not see the changes in the webapp behavior until I restarted uWSGI.
Yes, you need to restart the uWSGI process.
Python keeps the compiled code in memory so it won't get re-read until the process restarts. The django development server (manage.py runserver) actively monitors files for changes, but that won't happen by default with other servers. If you want to enable automatic reloading in uWSGI, the touch-reload and py-auto-reload uWSGI arguments might help.