Prevent scaling web/wsgi above a single worker (but allow turning them off)

pull/2/head
Rui Carmo 2016-04-02 17:46:11 +01:00
rodzic 24bfb2f80a
commit ae3f7608d4
2 zmienionych plików z 9 dodań i 3 usunięć

Wyświetl plik

@ -18,7 +18,7 @@ From the bottom up:
- [ ] Support barebones binary deployments
- [ ] CLI command documentation
- [ ] Complete installation instructions (see `INSTALL.md` for a working draft)
- [ ] Worker scaling
- [x] Worker scaling
- [x] Remote CLI commands for changing/viewing applied/live settings
- [x] Remote tailing of all logfiles for a single application
- [x] HTTP port selection (and per-app environment variables)

10
piku.py
Wyświetl plik

@ -502,11 +502,17 @@ def deploy_app(app, settings):
for s in settings:
try:
k, v = map(lambda x: x.strip(), s.split(":", 1))
c = int(v) # check for integer value
if k not in worker_count:
echo("Error: worker type '%s' not present in '%s'" % (k, app), fg='red')
return
_ = int(v) # check for integer value
worker_count[k] = v
elif k in ['web','wsgi'] and 0 <= c < 1:
echo("Error: cannot scale type '%s' above 1" % k, fg='red')
return
if c < 0 and int(worker_count[k] - c) >= 0:
v = worker_count[k] = worker_count[k] - c
else:
worker_count[k] = v
echo("Scaling %s to %s for '%s'" % (k, v, app), fg='white')
except:
echo("Error: malformed setting '%s'" % s, fg='red')