Saturday, September 28, 2013

Open Shift Django Basic

My 1 week research on various Paas ended at open shift.
I was a fan of heroku. Some pros of  openshift are 3 gears instead of 1 single dyno
and each gear have a 512MB memory, 1GB local storage than read only file system.
So a total of 1.5GB Ram and 3GB storage :)

Now coming to django to openshift

install rhc using

sudo gem install rhc

create an open shift app using

rhc app create APPNAME python-2.7 -s

-s is for auto scaling

edit setup.py

nano APPNAME/setup.py

uncomment the line install_requires=['Django==xxxxxxx
and change it according to the required django version if its 1.5.1

install_requires=['Django==1.5.1']

save and exit

git commit -am 'Initial commit'
git push


django app should be put in side wsgi

cd wsgi
django-admin.py startproject PROJECTNAME


edit the file application

nano application

delete the contents and paste the new contents

#!/usr/bin/python
import os, sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'PROJECTNAME.settings'
sys.path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'wsgi',
    'PROJECTNAME'))

virtenv = os.environ['APPDIR'] + '/virtenv/'
os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib/python2.6/site-packages')
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')

try:
    execfile(virtualenv, dict(__file__=virtualenv))
except IOError:
    pass

#
# IMPORTANT: Put any additional includes below this line.  If placed above this
# line, it's possible required libraries won't be in your searchable path
#
from django.core.handlers import wsgi
application = wsgi.WSGIHandler() 


Now push the changes

cd ..
git add .
git commit -a -m "Project Creation"
git push 


Wait for push to finish,

One drawback of openshift is the time take to restart an app after a change is pushed.

Sunday, September 01, 2013

Django FastCgi with Nginx

When Launching a  django app, Configuring an nginx virtual host is the most tedious thing. I never can write a configuration with out fiddling with it for a day.

So I descided to write a script for it to auto manage it,

Clone my git hub repo https://github.com/abhisheklalnediya/djangonginx

copy the StartServer.sh to the app directory
specify the port for nginx as the first argument
eg :
$ StartServer.sh 8011

What it does is:
1. Start django in fasctcgi
2. Generate an nginx virtual host configuration file
3. Reloads nginx
4. Happy :) ?

Saturday, May 12, 2012

Bug:Freezing gnome-shell after some work hours

A bug on Gnome shell,
when Gnome shell is used for some time, about an hour or more, i t hangs,
the mouse does not hangs.

So its the problem with gnome-shell.

Bug reported on redhat bugzill is availiable at bugzilla.redhat.com.

So for those guys this is really an annoying thing, there is a temporary solution  .



Go to tty1 by pressing

Ctrl + Alt + F1

Now login using user name and password, (Number pad doesn't work here)

On successful login

pkill gnome-shell

Now go back to GUi by

Ctrl + Alt + F7

Friday, September 16, 2011

[Solved] Fedora 15, 14 : Can't login using tty 1~6

From Fedora 14 , its not allowed to login  using tty.
Neither root nor other users can login using tty.
This problem is caused by a file in /etc/udev/rules.d/
So i deleted all the files in that folder.











Dont worry, it wont do any harm, I tested it in my F15
reboot the system

Now you can login using tty.
Some of the deleted files are automatically created after the reboot