Browse Source

Add gunicorn to Vagrant VM

master
Maik Hoepfel 12 years ago
parent
commit
61e888950b
2 changed files with 33 additions and 2 deletions
  1. 1
    0
      Vagrantfile
  2. 32
    2
      sites/puppet/manifests/site.pp

+ 1
- 0
Vagrantfile View File

@@ -13,6 +13,7 @@ Vagrant::Config.run do |config|
13 13
 	config.vm.forward_port 8000, 8080
14 14
 	config.vm.forward_port 80, 8081
15 15
 	config.vm.forward_port 9001, 9001
16
+	config.vm.forward_port 9002, 9002
16 17
 	#config.vm.boot_mode = :gui
17 18
     config.vm.provision :puppet do |puppet|
18 19
         puppet.manifests_path = "sites/puppet/manifests"

+ 32
- 2
sites/puppet/manifests/site.pp View File

@@ -27,14 +27,22 @@ node precise64 {
27 27
 	include python_dependencies
28 28
 	include userconfig
29 29
 
30
-	# Apache
30
+	# Apache serving WSGI on port 80 (would prefer 8081)
31 31
 	class {"apache": }
32 32
 	class {"apache::mod::wsgi": }
33 33
 	file {"/etc/apache2/sites-enabled/vagrant.conf":
34 34
 	    source => "/vagrant/sites/sandbox/deploy/apache2/vagrant.conf"
35 35
 	}
36 36
 
37
-	# Nginx in front of Apache
37
+	# gunicorn serving WSGI on unix socket
38
+	class { "python::gunicorn": owner => "root", group => "root" }
39
+	python::gunicorn::instance { "oscar":
40
+	  venv => "/var/www/virtualenv",
41
+	  django => true,
42
+	  src => "/vagrant/sites/sandbox",
43
+    }
44
+
45
+	# Nginx in front of Apache (port 9001)
38 46
 	class { "nginx": }
39 47
 	nginx::resource::vhost { 'apache_rp':
40 48
 	  ensure => present,
@@ -51,6 +59,28 @@ node precise64 {
51 59
 	  },
52 60
 	}
53 61
 
62
+	# Nginx in front of gunicorn (port 9002)
63
+	nginx::resource::vhost { 'gunicorn_rp':
64
+	  ensure => present,
65
+	  listen_port => 9002,
66
+	}
67
+	nginx::resource::location { 'gunicorn-root':
68
+	  ensure => present,
69
+	  vhost => 'gunicorn_rp',
70
+	  location => '/',
71
+	  proxy => 'http://app1',
72
+	  proxy_set_headers => {
73
+	  'REMOTE_ADDR' => '$remote_addr',
74
+	  'HTTP_HOST' => '$http_host',
75
+	  },
76
+	}
77
+	nginx::resource::upstream { 'app1':
78
+       ensure => present,
79
+       members => [
80
+       'unix:/run/gunicorn/oscar.sock weight=10',
81
+       ],
82
+    }
83
+
54 84
 	# Memcached
55 85
 	class {"memcached": max_memory => 64 }
56 86
 

Loading…
Cancel
Save