I'm creating Django app on OpenShift on Python 3.3 with no scaling, it works fine. So when I browse the app gives me a django url error and with /admin brings me the admin login page.
But as I create it with scaling I get this error
503 Service Unavailable
No server is available to handle this request.
I tried with small, small high.cpu none works for me with scaling but actually I need small high.cpu on eu.west region.
I also tried to create a Python 3.3 app with Scaling which works fine and then add Django through repository upstream or by adding my previous configuration with I had before still not working after complete push to repo.
I've done that before and had worked for me before, so please don't answer without testing it.
This is the link to HAProxy both local gear and backend are DOWN.
It seems there's something wrong with the current django quickstart for openshift. In your case the scaled app is returing a 503 error because the django app is producing a 404 error at it's root.
I've successfully deployed both scaling and none scaling using this repo: https://github.com/jsvgoncalves/django-openshift
Don't forget that the $OPENSHIFT_PYTHON_WSGI_APPLICATION environment variable needs to point to the right wsgi.py and that you may need to restart the app.
$ APP_NAME=yourapp
$ rhc env set OPENSHIFT_PYTHON_WSGI_APPLICATION=django_exp/wsgi.py -a $APP_NAME
# You may need to restart your app
$ rhc app-restart -a $APP_NAME
Also, create the database (or have it directly on your git repo, as everytime you'll push changes this database file will disappear):
$ rhc ssh -a $APP_NAME
$ cd app-root/runtime/repo
$ python manage.py migrate
Related
So I just deployed my Django app to Heroku, and everything is working fine. The current version of the app isn't perfect, so I want to edit it, but my current process is:
1. **make changes in files
2. git status (just to make sure changes are seen)
3. git add -A
4. git commit -m "message"
5. git push heroku master
How can I get back the whole python manage.py runserver development part so I can be more thorough with my changes, and only commit when I know the changes meet my expectations?
Since I'm new to Python/HTML/CSS, I'm always coding then testing to see what my code does, and it would involve a lot of git commit / git push currently. Any help is appreciated!
deploying to Heroku should not stop you from using python manage.py runserver. Just make sure that you have loaded up your virtual environment (if you are using one) and it should just work.
I am developing an app with django cookiecutter (with docker and heroku setup) and have come so far as to deploying it. This is my first ever project, so no prior experience with django, docker or heroku. I've read up on it at cookiecutter docs, heroku and a little on the docker website but I still don't how to deploy.
I have downloaded the heroki cli , have set up app on heroku with my own domain and a postgres db and I am planning on getting hobby tier to get the automated certificate. All environment variables are set in the .env file and are set in the heroku config vars in my app at heoku. So everything should be alright as far as code and settings. I am also using git as version control.
Am I supposed to upload the whole project (code, settings, docker files etc) to heroku with git or by some other means? I saw there was an option to deploy the project with docker deploys aswell at herokus website. What option is the correct one?
I was thinking initially that I would just upload the project through git and run docker-compose -f production.yml up (in the heroku bash)... or something like that and that. I dont know, please help.
If some info is missing or is unclear I will try edit it as best as I can.
It is better to deploy the project to Heroku using git.
$ heroku login
$ heroku create your_custom_app_name
$ git add --a
$ git commit -m "My custom app deployment to heroku"
$ git push heroku master
and then once it is deployed.
$ heroku python manage.py migrate
I have simple python script which I would like to host on Heroku and run it every 10 minutes using Heroku scheduler. So can someone explain me what I should type on the rake command at the scheduler and how I should change the Procfile of Heroku?
Sure, you need to do a few things:
Define a requirements.txt file in the root of your project that lists your dependencies. This is what Heroku will use to 'detect' you're using a Python app.
In the Heroku scheduler addon, just define the command you need to run to launch your python script. It will likely be something like python myscript.py.
Finally, you need to have some sort of web server that will listen on the proper Heroku PORT -- otherwise, Heroku will think your app isn't working and it will be in the 'crashed' state -- which isn't what you want. To satisfy this Heroku requirement, you can run a really simple Flask web server like this...
Code (server.py):
from os import environ
from flask import Flask
app = Flask(__name__)
app.run(environ.get('PORT'))
Then, in your Procfile, just say: web: python server.py.
And that should just about do it =)
If you use free account [unverified*] on Heroku (so you cannot install addons), instead of using "Heroku scheduler", use time.sleep(n). You don't need Flask or any server in this case, just place script, say, inside folder Scripts (in default app/project by Heroku) and add to Procfile: worker: python script.py. Of course you replace script.py with Path to your script, including name, ex. worker: python Scripts/my_script.py
Note: If your script uses third-party modules, say bs4 or requests, you need to install them in pipenv install MODULE_NAME or create requirements.txt and place it where manage.py, Procfile, Pipfile, (etc) are. Next place in that requirements.txt:
requirements.txt:
MODULE_NAME==MODULE_VERSION
You can check them in pip freeze | grep MODULE_NAME
Finally deploy to Heroku server using git and run following command:
heroku ps:scale worker=1
That's it! Bot/Script is running, check it in logs:
heroku logs --tail
Source: https://github.com/michaelkrukov/heroku-python-script
unverified* - "To help with abuse prevention, provisioning an add-on requires account verification. If your account has not been verified, you will be directed to visit the verification site." It redirects to Credit Card info. However you can still have Free Acc, but you will not be able to use certain options for free users, such as installing addons:https://devcenter.heroku.com/articles/getting-started-with-python#provision-add-ons
So I finished making a simple django app. All it is, is a website which has a /admin page, where someone can sign into and create posts which update to the site. Basically like a blog. I could've done it with WordPress but I prefer django a lot more. My last question is, how do I know host the django app as a website? I don't want a step by step guide, I know this site isn't meant for it but can someone give me a textbook or a link to something which shows how to do it? Because really I tried looking and couldn't find anything. The app isn't for me, it's for an organization and I don't know if their site is going to be .com, .net etc. And I don't know what they will be hosting the site on but I really don't want to end up having to redo everything with WordPress in order to just host the site.
You could host your app on Amazon EC2. If you Google Django + EC2, you will see lots of tutorials.
you can host use OPENSHIFT.
Create an account at http://openshift.redhat.com/
Install the RHC client tools if you have not already done so:
sudo gem install rhc
Create a python-2.6 application
rhc app create -a django -t python-2.6
Add this upstream repo
cd django
git remote add upstream -m master git://github.com/openshift/django-example.git
git pull -s recursive -X theirs upstream master
Then push the repo upstream
git push
Here, the admin user name and password will be displayed, so pay
special attention.
That's it. You can now checkout your application at:
http://django-$yournamespace.rhcloud.com
now the difficult part
you want to edit the files in folder django/wsgi/openshift
mostly you want to edit the settings.py and copy your project folder to this folder.
now check it in localhost ie python manage.py runserver. if it worked successfully you can call git push that is it.
https://www.heroku.com/ is awesome web-hosting with django support and totally simplified deployment process. Tutorial included.
I've downloaded google_appengine version 1.3.1. Using some web tutorials, I've created basic django 1.1.1 application. Using appcfg I managed to deploy it on GAE and it works. The problem is, that application doesn't want to work on dev_appengine.py developement server.
Whenever I run the app GAE local server is returning HTTP 200 without any content. If I set basic environement and run main.py manually, then the page is properly returned on stdout.
I've also created very basic helloworld application, and this one is working ok on the devel server.
Do you have any idea, how can I debug the devel server? Option -d doesn't give any usefull insight at all.
I had module nammed same way as the default GAE launcher (main/ and main.py). After renaming the launcher everything works great.