Commits

Alfonso de la Guarda Reyes committed 2ec8180

Python Deploy V1

Comments (0)

Files changed (6)

10gen-mongodb.repo

+[10gen]
+name=10gen Repository
+baseurl=http://downloads.mongodb.org/distros/centos/5.4/os/i386/
+gpgcheck=0
+Python Deploy
+=============
+
+
+Is a bash script which allows deploy any python based application inside
+CentOS.  The goal is just run the script and have the services up without
+further configurations.
+
+
+Installs:
+	- Python
+	- Mongodb
+	- Nginx
+	- Supervisor
+
+You can use the script as layout and modify according to your needs.
+
+The current template matchs for any Tornado behind Nginx installation, using
+supervisor as daemon manager.
+
+
+Under GPL v2
+
+Alfonso de la Guarda Reyes - 2011
+alfonsodg@gmail.com
+

SOAPpy-0.12.0-modified.tar.gz

Binary file added.

ictec_apps_centos.sh

+#!/bin/bash
+###
+#Guide for installation procedures for web applications
+#ICTEC SAC
+###
+echo "ICTEC SAC"
+echo "Instalación de servicios y aplicaciones"
+echo "---------------------------------------"
+###
+#Basic repositories and packages
+###
+#EPEL repository containing latest packages for CentOS
+#This step can be skipped if you think about compiling python and nginx
+echo "*** Installing EPEL"
+rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
+#Installation of basic services and packages for applications
+echo "*** Installing basic packages"
+#Overall system installed units of the standard repos
+yum -y install libxml2 libxslt libxml2-devel libxslt-devel gcc openssl-devel libjpeg*
+#Installing packages from EPEL repository
+#Board if it is not to use EPEL
+#Installs: ngnix (http server) and python (programming language)
+yum -y install nginx python26 python26-devel python26-distribute
+echo "++++++++++++++++++++++++++++++++++++++++++++"
+
+
+###
+#Updates curl library, CentOS has a very old
+###
+#Download and compile curl
+echo "*** Download and compile curl 7.21"
+wget http://curl.haxx.se/download/curl-7.21.3.tar.bz2
+tar xvfj curl-7.21.3.tar.bz2
+cd curl-7.21.3
+./configure
+make
+make install
+cd ..
+#Modify ld.so.conf
+echo "/lib" >> /etc/ld.so.conf
+echo " " >> /etc/ld.so.conf
+echo "/usr/lib" >> /etc/ld.so.conf
+echo " " >> /etc/ld.so.conf
+echo "/usr/local/lib" >> /etc/ld.so.conf
+echo " " >> /etc/ld.so.conf
+#Update locations of libraries, in this case curl
+ldconfig
+echo "++++++++++++++++++++++++++++++++++++++++++++"
+
+
+###
+#Operations for MongoDB, a database NoSQL
+###
+#Add new repository
+echo "*** Instalando MongoDB"
+cp 10gen-mongodb.repo /etc/yum.repos.d/
+#Installing MongoDB
+yum -y install mongo-stable mongo-stable-server
+#Mongod daemon configuration
+sleep 2
+chkconfig --levels 2345 mongod on
+echo "++++++++++++++++++++++++++++++++++++++++++++"
+
+
+###
+#Python
+###
+#Installing pip from setuptools
+echo "*** Working with setutools (python)"
+easy_install-2.6 pip
+echo "*** Installing basic modules"
+#Modules required for the applications
+#Modules on the OS
+pip install mercurial   #Version Control
+pip install supervisor  #Daemon manager
+#Modules for applications
+#(check installation documents to update the list)
+echo "*** Installing specific modules for applications"
+pip install pyopenssl
+pip install pycrypto
+pip install lxml
+pip install twisted
+pip install django
+pip install tornado
+pip install mongoengine
+pip install wtforms
+pip install xmpppy
+pip install pyquery
+pip install pygooglechart
+pip install suds
+pip install pyxml
+pip install fpconst
+pip install cython
+pip install httpagentparser
+pip install pil
+pip install pycurl
+pip install html2text
+#pip install bottle #Just to try Webservice
+echo "++++++++++++++++++++++++++++++++++++++++++++"
+
+
+###
+#Python modules from source
+###
+#SOAPpy
+echo "*** SOAPpy module"
+tar xvfz SOAPpy-0.12.0-modified.tar.gz
+cd SOAPpy-0.12.0
+python26 setup.py build
+python26 setup.py install 
+cd ..
+echo "++++++++++++++++++++++++++++++++++++++++++++"
+
+
+###
+#Management services by supervisor (demons)
+###
+echo "*** Configuring supervisor"
+#Default configuration is obtained
+echo_supervisord_conf > /etc/supervisord.conf
+#Is added at the end, lines for particular process management
+#OPTIONAL: You can manually add the configuration lines contained in each project
+cat supervisord.conf.add >> /etc/supervisord.conf
+#Logs directory is created
+mkdir /var/log/supervisor/
+#Configure the / etc / supervisord.conf to make corresponding changes to
+#the distribution (SO) and based on the configuration of each application
+#Review the installation process for each individual application configuration
+#model references or demon
+
+#Supervisord daemon configuration
+echo "*** Demonizing supervisord"
+#The daemon is added at the end of local file
+echo "supervisord" >> /etc/rc.local
+echo " " >> /etc/rc.local
+echo "++++++++++++++++++++++++++++++++++++++++++++"
+
+
+###
+#Nginx configuration and load balancing options
+###
+#Configuring nginx using configuration template that implements load balancing,
+#change according to the particular configuration selected for each service
+echo "*** Configuring nginx with load balancing"
+mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old
+cp nginx.conf.add /etc/nginx/nginx.conf
+
+#Nginx daemon configuration
+sleep 2
+chkconfig --levels 2345 nginx on
+echo "++++++++++++++++++++++++++++++++++++++++++++"
+
+
+###
+#Installing Applications by mercurial repository
+#(If you want to do individually, comment the lines below)
+#You must configure each application according to the guidance provided for each
+#Obviosuly, you can change mercurial for the dcvs of your choice
+###
+#echo "*** Downloading apps from Mercurial repos"
+#cd /var/www
+#hg clone https://hg.ictec.biz/appdemo-one
+#hg clone https://hg.ictec.biz/appdemo-two
+#hg clone https://hg.ictec.biz/appdemo-three
+#echo "++++++++++++++++++++++++++++++++++++++++++++"
+
+
+###
+#Initializing services
+###
+###
+#Warning
+###
+#Before proceeding to activate the services should be considered:
+# - Configuring Applications
+# - Set security permissions associated
+# - Check the hostname where access to services should
+# - Check that the local repositories, you always find the latest version: hg update
+###
+echo "*** Final tasks"
+echo "*** Starting mongod"
+#service mongod start
+echo "*** Starting nginx"
+#service nginx start
+echo "*** Starting supervisord"
+#supervisord
+echo "++++++++++++++++++++++++++++++++++++++++++++"
+user nginx;
+worker_processes 1;
+
+error_log /var/log/nginx/error.log;
+pid /var/run/nginx.pid;
+
+events {
+    worker_connections 1024;
+    use epoll;
+}
+
+http {
+    # Enumerate all the Tornado servers here
+    upstream frontends {
+        server 127.0.0.1:8888;
+#        server 127.0.0.1:8001;
+#        server 127.0.0.1:8002;
+#        server 127.0.0.1:8003;
+	}
+    upstream acortador {
+        server 127.0.0.1:8889;
+#        server 127.0.0.1:8001;
+#        server 127.0.0.1:8002;
+#        server 127.0.0.1:8003;
+	}
+
+
+    include /etc/nginx/mime.types;
+    default_type application/octet-stream;
+
+    access_log /var/log/nginx/access.log;
+
+    keepalive_timeout 65;
+    proxy_read_timeout 200;
+    sendfile on;
+    tcp_nopush on;
+    tcp_nodelay on;
+    gzip on;
+    gzip_min_length 1000;
+    gzip_proxied any;
+    gzip_types text/plain text/css text/xml
+               application/x-javascript application/xml
+               application/atom+xml text/javascript;
+
+    # Only retry if there was a communication error, not a timeout
+    # on the Tornado server (to avoid propagating "queries of death"
+    # to all frontends)
+    proxy_next_upstream error;
+
+    server {
+        listen 80 default;
+
+        server_name localhost 192.168.113 oauth.ictec.biz;
+
+        # Allow file uploads
+        client_max_body_size 50M;
+
+        location ^~ /static/ {
+            root /var/www/appdemo-three;
+            if ($query_string) {
+                expires max;
+            }
+        }
+
+        location ^~ /media/ {
+            root /var/www/appdemo-three;
+            if ($query_string) {
+                expires max;
+            }
+        }
+
+        location = /favicon.ico {
+            rewrite (.*) /static/favicon.ico;
+        }
+
+        location = /robots.txt {
+            rewrite (.*) /static/robots.txt;
+        }
+
+        location / {
+            proxy_pass_header Server;
+            proxy_set_header Host $http_host;
+#            proxy_redirect off;
+            proxy_set_header X-Real-IP $remote_addr;
+            proxy_set_header X-Scheme $scheme;
+            proxy_pass http://frontends;
+        }
+    }
+    server {
+#        listen 80 default;
+
+        server_name vms.ictec.biz;
+
+        # Allow file uploads
+#        client_max_body_size 50M;
+
+        location ^~ /static/ {
+            root /var/www/appdemo-two;
+            if ($query_string) {
+                expires max;
+            }
+        }
+
+        location ^~ /media/ {
+            root /var/www;
+            if ($query_string) {
+                expires max;
+            }
+        }
+
+        location = /favicon.ico {
+            rewrite (.*) /static/favicon.ico;
+        }
+
+        location = /robots.txt {
+            rewrite (.*) /static/robots.txt;
+        }
+
+        location / {
+            proxy_pass_header Server;
+            proxy_set_header Host $http_host;
+#            proxy_redirect off;
+            proxy_set_header X-Real-IP $remote_addr;
+            proxy_set_header X-Scheme $scheme;
+            proxy_pass http://acortador;
+        }
+    }
+}

supervisord.conf.add

+
+
+[group:ictec]
+programs=appdemo-three-8888,appdemo-two-8889,appdemo-one,appdemo-four,data_webservice
+
+
+[program:appdemo-three-8888]
+command=/var/www/appdemo-three/init_server.py
+directory=/var/www/appdemo-three
+autorestart=true
+redirect_stderr=true
+stdout_logfile=/var/log/supervisor/appdemo-three-8888.log
+stdout_logfile_maxbytes=500MB
+stdout_logfile_backups=50
+stdout_capture_maxbytes=1MB
+stdout_events_enabled=false
+loglevel=warn
+
+[program:appdemo-two-8889]
+command=/var/www/appdemo-two/init_server.py
+directory=/var/www/appdemo-two
+autorestart=true
+redirect_stderr=true
+stdout_logfile=/var/log/supervisor/appdemo-two-8889.log
+stdout_logfile_maxbytes=500MB
+stdout_logfile_backups=50
+stdout_capture_maxbytes=1MB
+stdout_events_enabled=false
+loglevel=warn
+
+
+[program:appdemo-one]
+command=/var/www/appdemo-one/service1.py 
+directory=/var/www/appdemo-one
+autorestart=true
+redirect_stderr=true
+stdout_logfile=/var/log/supervisor/service1.log
+stdout_logfile_maxbytes=500MB
+stdout_logfile_backups=50
+stdout_capture_maxbytes=1MB
+stdout_events_enabled=false
+loglevel=warn
+
+
+[program:appdemo-four]
+command=/var/www/appdemo-one/service2.py 
+directory=/var/www/appdemo-one
+autorestart=true
+redirect_stderr=true
+stdout_logfile=/var/log/supervisor/service2.log
+stdout_logfile_maxbytes=500MB
+stdout_logfile_backups=50
+stdout_capture_maxbytes=1MB
+stdout_events_enabled=false
+loglevel=warn
+
+
+[program:data_webservice]
+command=/var/www/appdemo-one/rest_api.py
+directory=/var/www/appdemo-one
+autorestart=true
+redirect_stderr=true
+stdout_logfile=/var/log/supervisor/rest_api.log
+stdout_logfile_maxbytes=500MB
+stdout_logfile_backups=50
+stdout_capture_maxbytes=1MB
+stdout_events_enabled=false
+loglevel=warn
+
+
+