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
1 parent
fbeff74
commit 7df7f81
Showing
15 changed files
with
109 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
Django==1.2.3 | ||
Fabric==0.9.2 | ||
paramiko==1.7.6 | ||
pycrypto==2.0.1 | ||
wsgiref==0.1.2 | ||
|
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
5 changes: 5 additions & 0 deletions
5
rockets/hostings/templates/uwsgi-gitdeploy/ubuntu/SCRIPTS/postinst
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,5 @@ | ||
cd /home/{{name}}/{{name}}.git | ||
git config core.worktree /home/{{name}}/uwsgi/app{{secret}} | ||
|
||
chmod +x /home/{{name}}/{{name}}.git/hooks/post-update | ||
|
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
4 changes: 4 additions & 0 deletions
4
rockets/hostings/templates/uwsgi/ubuntu/home/{{name}}/conf/wsgi{{secret}}.py
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
File renamed without changes.
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 +1 @@ | ||
[{"pk": "node", "model": "rocket.session", "fields": {"value": "localhost"}}, {"pk": 1, "model": "rocket.node", "fields": {"username": "root", "name": "localhost", "storage": "{}", "public_ip": "[\"127.0.0.1\"]", "private_ip": "[\"127.0.0.1\"]", "provider": null, "services": "[]", "os": "ubuntu"}}] | ||
[{"pk": "node", "model": "rocket.session", "fields": {"value": "localhost"}}, {"pk": 1, "model": "rocket.node", "fields": {"username": "root", "name": "localhost", "storage": "{}", "port": 22, "public_ip": "[\"127.0.0.1\"]", "private_ip": "[\"127.0.0.1\"]", "provider": null, "services": "[]", "os": "ubuntu"}}] |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python | ||
#-*- coding:utf-8 -*- | ||
import os | ||
import json | ||
|
||
from fabric.api import put, run, local, cd, settings, env, hide, show | ||
from django.core.management.base import NoArgsCommand, BaseCommand, CommandError | ||
from rockets import models | ||
from rockets import loaders | ||
from rockets import conf | ||
|
||
class Command(BaseCommand): | ||
def handle(self, *args, **kwargs): | ||
node = models.Node.current() | ||
|
||
public_ip = json.loads(node.public_ip or "[]")[0] | ||
env.hosts = [public_ip] | ||
env.user = user = node.username | ||
env.port = port = node.port | ||
env.bundle = bundle = models.Session.bundle() | ||
env.secret = secret = os.urandom(5).encode('hex') | ||
env.secret2 = secret2 = os.urandom(5).encode('hex') | ||
env.host_string = '%(user)s@%(public_ip)s:%(port)s' % locals() | ||
|
||
dump_path = os.path.join(conf.SERVER_DUMP_PATH, node.name) | ||
script_path = os.path.join(conf.SERVER_DUMP_PATH, node.name, 'SCRIPTS') | ||
bundle_path = '/tmp/rocket-%(bundle)s' % env | ||
bundle_script_path = os.path.join(bundle_path, 'SCRIPTS') | ||
|
||
scripts = [ x for x in os.listdir(script_path) if not x.endswith('~') ] | ||
scripts.sort() | ||
try: | ||
with cd(dump_path): | ||
local('tar czf /tmp/rocket-%(secret)s.tar.gz *' % locals(), capture=False) | ||
put('/tmp/rocket-%(secret)s.tar.gz' % env, '/tmp/rocket-%(secret2)s.tar.gz' % env) | ||
run('mkdir -p /tmp/rocket-%(bundle)s' % env, pty=True) | ||
run('tar xzf /tmp/rocket-%(secret2)s.tar.gz --no-overwrite-dir --directory=/tmp/rocket-%(bundle)s' % env, pty=True) | ||
|
||
if scripts: | ||
run('chmod +x %(bundle_path)s/SCRIPTS/*' % locals()) | ||
for script in scripts: | ||
run('%(bundle_path)s/SCRIPTS/%(script)s' % locals(), pty=True) | ||
os.remove(os.path.join('SCRIPTS', script)) | ||
finally: | ||
with hide('running', 'stdout', 'stderr'): | ||
run('rm -rf /tmp/rocket-%(secret2)s.tar.gz' % locals()) | ||
run('rm -rf /tmp/rocket-%(bundle)s' % locals()) | ||
local('rm -rf /tmp/rocket-%(secret)s*' % locals()) | ||
|
||
|
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