kopia lustrzana https://github.com/piku/piku
First pass at configuration
rodzic
c77bc91d36
commit
1d3ad2d528
12
INSTALL.md
12
INSTALL.md
|
@ -216,6 +216,18 @@ sudo update-rc.d uwsgi-piku defaults
|
|||
sudo service uwsgi-piku start
|
||||
```
|
||||
|
||||
## nginx Installation (Raspbian 8, Ubuntu 16.04)
|
||||
|
||||
```bash
|
||||
sudo apt-get install nginx incron
|
||||
# Set up nginx to pick up our config files
|
||||
sudo cp /tmp/nginx.default.dist /etc/nginx/sites-available/default
|
||||
# Set up incron to reload nginx upon config changes
|
||||
sudo cp /tmp/incron.dist /etc/incron.d/piku
|
||||
sudo systemctl restart incron
|
||||
sudo systemctl restart nginx
|
||||
```
|
||||
|
||||
## Go Installation (All Debian Linux variants, on Raspberry Pi)
|
||||
|
||||
> This is **EXPERIMENTAL** and may not work at all.
|
||||
|
|
|
@ -48,7 +48,7 @@ As of April 2016, the shipping versions with Raspbian are recent enough to run `
|
|||
|
||||
```bash
|
||||
# as 'pi' user
|
||||
sudo apt install -y python-virtualenv python-pip git uwsgi uwsgi-plugin-python
|
||||
sudo apt install -y python-virtualenv python-pip git uwsgi uwsgi-plugin-python incron nginx
|
||||
sudo pip install -U click
|
||||
sudo reboot
|
||||
```
|
||||
|
|
|
@ -18,6 +18,7 @@ From the bottom up:
|
|||
- [ ] Sample Go app
|
||||
- [ ] Support Go deployments
|
||||
- [ ] CLI command documentation
|
||||
- [ ] nginx support
|
||||
- [x] Testing with pre-packaged [uWSGI][uwsgi] versions on Debian Jessie (yes, it was painful)
|
||||
- [x] Support barebones binary deployments
|
||||
- [x] Complete installation instructions (see `INSTALL.md`, which also has a draft of Go installation steps)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/home/piku/.piku/nginx IN_MODIFY,IN_NO_LOOP /bin/systemctl reload nginx
|
|
@ -0,0 +1,28 @@
|
|||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
# SSL configuration
|
||||
#
|
||||
# listen 443 ssl default_server;
|
||||
# listen [::]:443 ssl default_server;
|
||||
#
|
||||
# Self signed certs generated by the ssl-cert package
|
||||
# Don't use them in a production server!
|
||||
#
|
||||
# include snippets/snakeoil.conf;
|
||||
|
||||
root /var/www/html;
|
||||
|
||||
# Add index.php to the list if you are using PHP
|
||||
index index.html index.htm;
|
||||
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
# First attempt to serve request as file, then
|
||||
# as directory, then fall back to displaying a 404.
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
include /home/piku/.piku/nginx/*.conf;
|
||||
}
|
32
piku.py
32
piku.py
|
@ -18,11 +18,39 @@ APP_ROOT = abspath(join(PIKU_ROOT, "apps"))
|
|||
ENV_ROOT = abspath(join(PIKU_ROOT, "envs"))
|
||||
GIT_ROOT = abspath(join(PIKU_ROOT, "repos"))
|
||||
LOG_ROOT = abspath(join(PIKU_ROOT, "logs"))
|
||||
NGINX_ROOT = abspath(join(PIKU_ROOT, "nginx"))
|
||||
UWSGI_AVAILABLE = abspath(join(PIKU_ROOT, "uwsgi-available"))
|
||||
UWSGI_ENABLED = abspath(join(PIKU_ROOT, "uwsgi-enabled"))
|
||||
UWSGI_ROOT = abspath(join(PIKU_ROOT, "uwsgi"))
|
||||
UWSGI_LOG_MAXSIZE = '1048576'
|
||||
|
||||
NGINX_TEMPLATE = """
|
||||
upstream $APP {
|
||||
server $BIND_ADDRESS:$PORT;
|
||||
}
|
||||
server {
|
||||
listen [::]:80;
|
||||
listen 80;
|
||||
server_name $NOSSL_SERVER_NAME;
|
||||
access_log $LOG_ROOT/$APP-access.log;
|
||||
error_log $LOG_ROOT/$APP-error.log;
|
||||
|
||||
# set a custom header for requests
|
||||
add_header X-Deployed-By Piku;
|
||||
|
||||
location / {
|
||||
proxy_pass http://$APP;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
proxy_set_header X-Request-Start $msec;
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
# === Utility functions ===
|
||||
|
||||
|
@ -486,6 +514,8 @@ def destroy_app(app):
|
|||
for f in g:
|
||||
echo("Removing file '%s'" % f, fg='yellow')
|
||||
os.remove(f)
|
||||
echo("Removing file '%s.conf'" % join(NGINX_ROOT,app), fg='yellow')
|
||||
os.remove(join(NGINX_ROOT, "%s.conf" % app))
|
||||
|
||||
|
||||
@piku.command("logs")
|
||||
|
@ -569,7 +599,7 @@ def init_paths():
|
|||
"""Initialize environment"""
|
||||
|
||||
# Create required paths
|
||||
for p in [APP_ROOT, GIT_ROOT, ENV_ROOT, UWSGI_ROOT, UWSGI_AVAILABLE, UWSGI_ENABLED, LOG_ROOT]:
|
||||
for p in [APP_ROOT, GIT_ROOT, ENV_ROOT, UWSGI_ROOT, UWSGI_AVAILABLE, UWSGI_ENABLED, LOG_ROOT, NGINX_ROOT]:
|
||||
if not exists(p):
|
||||
echo("Creating '%s'." % p, fg='green')
|
||||
os.makedirs(p)
|
||||
|
|
Ładowanie…
Reference in New Issue