0001-agent-use-lock-on-hobo-deploy-wait-for-10s-7534.patch
debian/control | ||
---|---|---|
30 | 30 |
Package: hobo-agent |
31 | 31 |
Architecture: all |
32 | 32 |
Depends: python-hobo (= ${binary:Version}), |
33 |
sudo, supervisor |
|
33 |
sudo, |
|
34 |
supervisor, |
|
35 |
python-lockfile |
|
34 | 36 |
Description: Rapid Remote Deployment Agent |
35 | 37 |
hobo/agent/worker/services.py | ||
---|---|---|
1 |
import ConfigParser |
|
2 | 1 |
import fnmatch |
3 | 2 |
import json |
4 | 3 |
import logging |
5 | 4 |
import os |
6 |
import string |
|
7 | 5 |
import subprocess |
8 | 6 |
import urllib2 |
9 |
import urlparse |
|
7 |
from lockfile import FileLock, LockTimeout |
|
10 | 8 | |
11 | 9 |
from . import settings |
12 | 10 | |
... | ... | |
14 | 12 | |
15 | 13 | |
16 | 14 |
class BaseService(object): |
17 |
def __init__(self, base_url, title, secret_key, **kwargs): |
|
15 |
def __init__(self, base_url, title, secret_key, slug, **kwargs):
|
|
18 | 16 |
self.base_url = base_url |
19 | 17 |
self.title = title |
20 | 18 |
self.secret_key = secret_key |
19 |
self.slug = slug |
|
21 | 20 | |
22 | 21 |
def is_for_us(self): |
23 | 22 |
# This function checks if the requested service is to be hosted |
... | ... | |
107 | 106 |
if service_obj.check_timestamp(hobo_timestamp): |
108 | 107 |
logger.debug('skipping uptodate site: %r', service_obj) |
109 | 108 |
continue |
110 |
service_obj.execute(environment) |
|
109 |
lock = FileLock(os.path.join(settings.LOCKDIR, |
|
110 |
'hobo-deploy-%s-%s.lock' % (service_id, service_obj.slug))) |
|
111 |
try: |
|
112 |
lock.acquire(timeout=settings.LOCKTIMEOUT) |
|
113 |
except LockTimeout: |
|
114 |
logger.warning('skipping as locked by other hobo-deploy: %r', service_obj) |
|
115 |
continue |
|
116 |
try: |
|
117 |
logger.debug('hobo-deploy: %r', service_obj) |
|
118 |
service_obj.execute(environment) |
|
119 |
except: |
|
120 |
lock.release() |
|
121 |
raise |
|
122 |
lock.release() |
hobo/agent/worker/settings.py | ||
---|---|---|
23 | 23 |
PASSERELLE_MANAGE_COMMAND = '/usr/lib/passerelle/manage.py' |
24 | 24 |
FARGO_MANAGE_COMMAND = '/usr/bin/fargo-manage' |
25 | 25 | |
26 |
# where to put lock files, used when run hobo-deploy commands |
|
27 |
LOCKDIR = '/var/tmp/' |
|
28 |
LOCKTIMEOUT = 10 |
|
29 | ||
26 | 30 |
local_settings_file = os.environ.get('HOBO_AGENT_SETTINGS_FILE', |
27 | 31 |
os.path.join(os.path.dirname(__file__), 'local_settings.py')) |
28 | 32 |
if os.path.exists(local_settings_file): |
requirements.txt | ||
---|---|---|
2 | 2 |
-e git+http://repos.entrouvert.org/gadjo.git/#egg=gadjo |
3 | 3 |
celery |
4 | 4 |
django-mellon |
5 |
lockfile |
|
5 |
- |