Skip to content

Commit

Permalink
initial import 😎
Browse files Browse the repository at this point in the history
  • Loading branch information
avinassh committed Jun 27, 2014
1 parent 83b62a6 commit 020fdae
Show file tree
Hide file tree
Showing 19 changed files with 143 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .openshift/action_hooks/README.md
@@ -0,0 +1,3 @@
For information about action hooks supported by OpenShift, consult the documentation:

http://openshift.github.io/documentation/oo_user_guide.html#the-openshift-directory
23 changes: 23 additions & 0 deletions .openshift/cron/README.cron
@@ -0,0 +1,23 @@
Run scripts or jobs on a periodic basis
=======================================
Any scripts or jobs added to the minutely, hourly, daily, weekly or monthly
directories will be run on a scheduled basis (frequency is as indicated by the
name of the directory) using run-parts.

run-parts ignores any files that are hidden or dotfiles (.*) or backup
files (*~ or *,) or named *.{rpmsave,rpmorig,rpmnew,swp,cfsaved}

The presence of two specially named files jobs.deny and jobs.allow controls
how run-parts executes your scripts/jobs.
jobs.deny ===> Prevents specific scripts or jobs from being executed.
jobs.allow ===> Only execute the named scripts or jobs (all other/non-named
scripts that exist in this directory are ignored).

The principles of jobs.deny and jobs.allow are the same as those of cron.deny
and cron.allow and are described in detail at:
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/ch-Automating_System_Tasks.html#s2-autotasks-cron-access

See: man crontab or above link for more details and see the the weekly/
directory for an example.

PLEASE NOTE: The Cron cartridge must be installed in order to run the configured jobs.
Empty file.
Empty file.
Empty file.
Empty file.
16 changes: 16 additions & 0 deletions .openshift/cron/weekly/README
@@ -0,0 +1,16 @@
Run scripts or jobs on a weekly basis
=====================================
Any scripts or jobs added to this directory will be run on a scheduled basis
(weekly) using run-parts.

run-parts ignores any files that are hidden or dotfiles (.*) or backup
files (*~ or *,) or named *.{rpmsave,rpmorig,rpmnew,swp,cfsaved} and handles
the files named jobs.deny and jobs.allow specially.

In this specific example, the chronograph script is the only script or job file
executed on a weekly basis (due to white-listing it in jobs.allow). And the
README and chrono.dat file are ignored either as a result of being black-listed
in jobs.deny or because they are NOT white-listed in the jobs.allow file.

For more details, please see ../README.cron file.

1 change: 1 addition & 0 deletions .openshift/cron/weekly/chrono.dat
@@ -0,0 +1 @@
Time And Relative D...n In Execution (Open)Shift!
3 changes: 3 additions & 0 deletions .openshift/cron/weekly/chronograph
@@ -0,0 +1,3 @@
#!/bin/bash

echo "`date`: `cat $(dirname \"$0\")/chrono.dat`"
12 changes: 12 additions & 0 deletions .openshift/cron/weekly/jobs.allow
@@ -0,0 +1,12 @@
#
# Script or job files listed in here (one entry per line) will be
# executed on a weekly-basis.
#
# Example: The chronograph script will be executed weekly but the README
# and chrono.dat files in this directory will be ignored.
#
# The README file is actually ignored due to the entry in the
# jobs.deny which is checked before jobs.allow (this file).
#
chronograph

7 changes: 7 additions & 0 deletions .openshift/cron/weekly/jobs.deny
@@ -0,0 +1,7 @@
#
# Any script or job files listed in here (one entry per line) will NOT be
# executed (read as ignored by run-parts).
#

README

Empty file added .openshift/markers/.gitkeep
Empty file.
26 changes: 26 additions & 0 deletions app.py
@@ -0,0 +1,26 @@
#!/usr/bin/env python

#
# This file may be used instead of Apache mod_wsgi to run your python
# web application in a different framework. A few examples are
# provided (cherrypi, gevent), but this file may be altered to run
# whatever framework is desired - or a completely customized service.
#

import imp
import os

try:
zvirtenv = os.path.join(os.environ['OPENSHIFT_PYTHON_DIR'],
'virtenv', 'bin', 'activate_this.py')
execfile(zvirtenv, dict(__file__ = zvirtenv) )
except IOError:
pass

if __name__ == '__main__':
ip = os.environ['OPENSHIFT_PYTHON_IP']
port = int(os.environ['OPENSHIFT_PYTHON_PORT'])
app = imp.load_source('application', 'main.py')

app.application.listen(port , ip)
app.ioloop.IOLoop.instance().start()
24 changes: 24 additions & 0 deletions main.py
@@ -0,0 +1,24 @@
#!/usr/bin/env python

import os
from tornado import ioloop,web
from tornado.escape import json_encode

class IndexHandler(web.RequestHandler):
def get(self):
self.render("index.html")

settings = {
"template_path": os.path.join(os.path.dirname(__file__), "templates"),
"static_path": os.path.join(os.path.dirname(__file__), "static"),
"debug" : True
}

application = web.Application([
(r'/', IndexHandler),
(r'/index', IndexHandler),
],**settings)

if __name__ == "__main__":
application.listen(8888)
ioloop.IOLoop.instance().start()
10 changes: 10 additions & 0 deletions setup.py
@@ -0,0 +1,10 @@
from setuptools import setup

setup(name='Avinash Sajjanshetty',
version='0.1',
description='Tornado Starter Kit',
author='Avinash Sajjanshetty',
author_email='avinashsajjan@gmail.com',
url='http://www.python.org/sigs/distutils-sig/',
install_requires=['tornado', 'requests', 'beautifulsoup4'],
)
5 changes: 5 additions & 0 deletions static/css/style.css
@@ -0,0 +1,5 @@
body{
width: 960px;
margin: 0 auto;
font-family: georgia;
}
Binary file added static/images/tornado.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added static/js/script.js
Empty file.
13 changes: 13 additions & 0 deletions templates/index.html
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>Simple Openshift Tornado App</title>
<link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
<img src="/static/images/tornado.png">
<p>This is a simple example to show how Tornado can be deployed on Openshift easily.</p>
<br />
<p>Fork the repo from <a href="https://github.com/avinassh/openshift-tornado-starter">here!</a></p>
</body>
</html>

0 comments on commit 020fdae

Please sign in to comment.