This repository has been archived by the owner on Oct 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
294 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# include: | ||
# - system | ||
include: | ||
- core.system | ||
|
||
packages: | ||
pkg.installed: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# app.conf | ||
|
||
# the upstream component nginx needs to connect to | ||
upstream django { | ||
server unix:///tmp/app.sock; # for a file socket | ||
} | ||
|
||
# configuration of the server | ||
server { | ||
# the port your site will be served on | ||
listen 80; | ||
# the domain name it will serve for | ||
server_name 0.0.0.0; # substitute your machine's IP address or FQDN | ||
charset utf-8; | ||
|
||
# max upload size | ||
client_max_body_size 75M; # adjust to taste | ||
|
||
# Django media | ||
#location /media { | ||
# alias /path/to/your/django/media; # your Django project's media files | ||
#} | ||
|
||
location /static { | ||
alias /home/vagrant/app/static; # your Django project's static files | ||
} | ||
|
||
# Finally, send all non-media requests to the Django server. | ||
location / { | ||
uwsgi_pass django; | ||
include uwsgi_params; | ||
# include /home/vagrant/app/uwsgi_params; # the uwsgi_params file you installed | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# nginx/init.sls | ||
|
||
include: | ||
- uwsgi | ||
|
||
nginx: | ||
pkg: | ||
- installed | ||
service: | ||
- running | ||
- enable: True | ||
- reload: True | ||
- require: | ||
- pkg: nginx | ||
- file: /etc/nginx/nginx.conf | ||
- file: /etc/nginx/sites-available/app.conf | ||
- file: /etc/nginx/sites-enabled/app.conf | ||
- file: /etc/nginx/sites-enabled/default | ||
- service: uwsgi | ||
- watch: | ||
- service: uwsgi | ||
|
||
/etc/nginx/nginx.conf: | ||
file: | ||
- managed | ||
- source: salt://nginx/nginx.conf | ||
- require: | ||
- pkg: nginx | ||
|
||
/etc/nginx/sites-available/app.conf: | ||
file: | ||
- managed | ||
- source: salt://nginx/app.conf | ||
- require: | ||
- pkg: nginx | ||
|
||
/etc/nginx/sites-enabled/app.conf: | ||
file: | ||
- symlink | ||
- target: /etc/nginx/sites-available/app.conf | ||
- require: | ||
- file: /etc/nginx/sites-available/app.conf | ||
|
||
/etc/nginx/sites-enabled/default: | ||
file: | ||
- absent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
user vagrant;#www-data; | ||
worker_processes 4; | ||
pid /run/nginx.pid; | ||
|
||
events { | ||
worker_connections 768; | ||
# multi_accept on; | ||
} | ||
|
||
http { | ||
|
||
## | ||
# Basic Settings | ||
## | ||
|
||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
keepalive_timeout 65; | ||
types_hash_max_size 2048; | ||
# server_tokens off; | ||
|
||
# server_names_hash_bucket_size 64; | ||
# server_name_in_redirect off; | ||
|
||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
## | ||
# Logging Settings | ||
## | ||
|
||
access_log /var/log/nginx/access.log; | ||
error_log /var/log/nginx/error.log; | ||
|
||
## | ||
# Gzip Settings | ||
## | ||
|
||
gzip on; | ||
gzip_disable "msie6"; | ||
|
||
# gzip_vary on; | ||
# gzip_proxied any; | ||
# gzip_comp_level 6; | ||
# gzip_buffers 16 8k; | ||
# gzip_http_version 1.1; | ||
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; | ||
|
||
## | ||
# nginx-naxsi config | ||
## | ||
# Uncomment it if you installed nginx-naxsi | ||
## | ||
|
||
#include /etc/nginx/naxsi_core.rules; | ||
|
||
## | ||
# nginx-passenger config | ||
## | ||
# Uncomment it if you installed nginx-passenger | ||
## | ||
|
||
#passenger_root /usr; | ||
#passenger_ruby /usr/bin/ruby; | ||
|
||
## | ||
# Virtual Host Configs | ||
## | ||
|
||
include /etc/nginx/conf.d/*.conf; | ||
include /etc/nginx/sites-enabled/*; | ||
} | ||
|
||
|
||
#mail { | ||
# # See sample authentication script at: | ||
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript | ||
# | ||
# # auth_http localhost/auth.php; | ||
# # pop3_capabilities "TOP" "USER"; | ||
# # imap_capabilities "IMAP4rev1" "UIDPLUS"; | ||
# | ||
# server { | ||
# listen localhost:110; | ||
# protocol pop3; | ||
# proxy on; | ||
# } | ||
# | ||
# server { | ||
# listen localhost:143; | ||
# protocol imap; | ||
# proxy on; | ||
# } | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,6 @@ base: | |
- core | ||
- virtualenv | ||
- postgresql | ||
- app | ||
- app | ||
- uwsgi | ||
- nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# mysite_uwsgi.ini file | ||
[uwsgi] | ||
|
||
# Django-related settings | ||
# the base directory (full path) | ||
chdir = /home/vagrant/app | ||
# Django's wsgi file | ||
# TODO: Investigate if we can set a generic name, or a pillar var. | ||
module = wsgi | ||
|
||
# the virtualenv (full path) | ||
# TODO: Build a venv and run uWSGI from it. | ||
home = /home/vagrant/venv | ||
|
||
# process-related settings | ||
# master | ||
master = true | ||
# maximum number of worker processes | ||
processes = 10 | ||
# the socket (use the full path to be safe | ||
socket = /tmp/app.sock | ||
# ... with appropriate permissions - may be needed | ||
chmod-socket = 664 | ||
# clear environment on exit | ||
vacuum = true | ||
|
||
# Environment variables | ||
env = DATABASE_URL=postgresql://{{ pillar['dbuser'] }}:{{ pillar['dbpassword'] }}@localhost:5432/{{ pillar['dbname'] }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# uwsgi/init.sls | ||
|
||
# include: | ||
# - dependencies | ||
|
||
/etc/uwsgi/apps-available/app_wsgi.ini: | ||
file: | ||
- managed | ||
- source: salt://uwsgi/app_wsgi.ini | ||
- user: vagrant | ||
- group: vagrant | ||
- makedirs: True | ||
- template: jinja | ||
- mode: 755 | ||
# - require: | ||
# - pkg: python3-pip | ||
# - cmd: install-requirements | ||
|
||
/etc/uwsgi/apps-enabled/app_wsgi.ini: | ||
file: | ||
- symlink | ||
- target: /etc/uwsgi/apps-available/app_wsgi.ini | ||
- makedirs: True | ||
- require: | ||
- file: /etc/uwsgi/apps-available/app_wsgi.ini | ||
|
||
/etc/init/uwsgi.conf: | ||
file: | ||
- managed | ||
- source: salt://uwsgi/uwsgi.conf | ||
- file_mode: 744 | ||
# - require: | ||
# - pkg: python3-pip | ||
# - cmd: install-requirements | ||
|
||
/var/log/uwsgi: | ||
file: | ||
- directory | ||
- user: vagrant | ||
- group: vagrant | ||
- makedirs: True | ||
# - require: | ||
# - pkg: python3-pip | ||
# - cmd: install-requirements | ||
|
||
uwsgi: | ||
service: | ||
- running | ||
- enable: True | ||
- require: | ||
- file: /etc/uwsgi/apps-enabled/app_wsgi.ini | ||
- file: /etc/init/uwsgi.conf | ||
- file: /var/log/uwsgi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# simple uWSGI script | ||
|
||
description "uWSGI in emperor mode" | ||
start on runlevel [2345] | ||
stop on runlevel [06] | ||
|
||
exec uwsgi --master --emperor /etc/uwsgi/apps-enabled --uid vagrant --gid vagrant --chmod-socket --die-on-term --logto /var/log/uwsgi/emperor.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import os | ||
from app import create_app | ||
|
||
application = create_app(os.getenv('FLASK_CONFIG') or 'default') | ||
|
||
if __name__ == "__main__": | ||
application.run(host='0.0.0.0') |