Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 098b679

Browse files
authored
Merge pull request alphagov#234 from alphagov/add-rbenv
Add rbenv script
2 parents 520c2d2 + 79cdfdf commit 098b679

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

fabfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import performanceplatform
3636
import postgresql
3737
import rabbitmq
38+
import rbenv
3839
import rkhunter
3940
import statsd
4041
import vm

rbenv.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from fabric.api import run, sudo, task, hide
2+
from fabric.contrib.files import exists
3+
4+
5+
@task
6+
def version_in_use(version):
7+
"""Tests whether an rbenv version is in use on a machine."""
8+
9+
rbenv_path = '/usr/lib/rbenv/versions/{0}/'.format(version)
10+
11+
with hide('running'):
12+
with hide('output'):
13+
if exists(rbenv_path):
14+
pids = sudo("lsof +D {0} | tail -n +2 | tr -s ' ' | cut -f 2 -d ' ' | sort -n | uniq".format(rbenv_path)).split('\r\n')
15+
else:
16+
pids = []
17+
for pid in pids:
18+
if pid == '':
19+
continue
20+
run('ps --no-headers {0}'.format(pid))

0 commit comments

Comments
 (0)