Compare commits
42 Commits
Author | SHA1 | Date | |
---|---|---|---|
e119234161 | |||
d85ba96a41 | |||
ca2132f372 | |||
6b280d357a | |||
e974481688 | |||
7819cdda0d | |||
38a592e29e | |||
1c3901af27 | |||
73e46f0ce9 | |||
560629e5bb | |||
f1b329b7d7 | |||
a0811cc7cc | |||
ea34a46d75 | |||
b0b73cdb45 | |||
7be2696c71 | |||
ece6c19ca3 | |||
bc1bb7fea2 | |||
28160bb7eb | |||
0cfb5e54f9 | |||
bfba08b1db | |||
847407beee | |||
7437a9fe3b | |||
7fc8010a60 | |||
2f3dacb569 | |||
e0963c1c29 | |||
3a060d5477 | |||
994a3297c9 | |||
5fef77b61f | |||
b1a9be254b | |||
f9b14cb38d | |||
591d5249cf | |||
7f65e0a420 | |||
ee40dcc7f6 | |||
67a7f77599 | |||
6a27b88465 | |||
d91df030be | |||
2d027afa29 | |||
27afb67a17 | |||
61af6f62b6 | |||
3ff71a5114 | |||
84ad1d92ec | |||
721e94e1e8 |
59
create.sh
59
create.sh
@ -1,46 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
name="$1"
|
||||
sshURL="$2"
|
||||
nodePort=`python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'`
|
||||
workingPath=/var/www/gitwrapper/$name
|
||||
|
||||
echo "starting $sshURL on $name"
|
||||
|
||||
eval "$(ssh-agent -s)"
|
||||
ssh-add /root/.ssh/id_github_rsa
|
||||
mkdir /var/www/gitwrapper/$name
|
||||
cd /var/www/gitwrapper/$name
|
||||
mkdir $workingPath
|
||||
cd $workingPath
|
||||
chmod 777 .
|
||||
echo `pwd`
|
||||
|
||||
DJANGO_SETTINGS_MODULE=project.settings.prod
|
||||
export DJANGO_SETTINGS_MODULE=project.settings.prod
|
||||
|
||||
NODE_ENV='staging'
|
||||
export NODE_ENV='staging'
|
||||
export NODEPORT=$nodePort
|
||||
|
||||
git clone $sshURL .
|
||||
virtualenv ./env
|
||||
|
||||
./scripts/setup.sh
|
||||
|
||||
source env/bin/activate
|
||||
pip install -r requirements.txt
|
||||
|
||||
cp /var/www/local_settings.py project/settings/local_settings.py
|
||||
echo "BRANCH = '$name'" >> project/settings/local_settings.py
|
||||
echo "BRANCH='$name'" >> project/settings/local_settings.py
|
||||
echo "NODEPORT='$nodePort'" >> project/settings/local_settings.py
|
||||
echo $nodePort > env/nodePort
|
||||
|
||||
python manage.py createcachetable
|
||||
echo "checking out to prod for set up"
|
||||
git checkout prod
|
||||
|
||||
python3 manage.py createcachetable
|
||||
python3 manage.py migrate
|
||||
python3 manage.py loaddata "/var/www/django.json"
|
||||
python3 manage.py loaddata /var/www/django.json
|
||||
|
||||
echo "checking out to $name for set up"
|
||||
git checkout $name
|
||||
|
||||
pip install -r requirements.txt
|
||||
./scripts/setup.sh
|
||||
|
||||
python3 manage.py collectstatic --noinput
|
||||
python3 manage.py migrate
|
||||
chmod 777 .
|
||||
chmod 777 db.sqlite3
|
||||
|
||||
forever stop $workingPath/node_rtc/app.js
|
||||
echo "starting node app on port $nodePort"
|
||||
forever start $workingPath/node_rtc/app.js -l
|
||||
|
||||
echo "creating apache VirtualHost file"
|
||||
|
||||
echo "<VirtualHost *:80>" > /etc/apache2/sites-enabled/$name.conf
|
||||
echo " ServerName $name.staging.bytedev.co" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo " Alias /static /var/www/gitwrapper/$name/staticfiles" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo " WSGIDaemonProcess $name python-path=/var/www/gitwrapper/$name:/var/www/gitwrapper/$name/env:/var/www/gitwrapper/$name/env/lib/python3.5/site-packages" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo " Alias /static $workingPath/staticfiles" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo " WSGIDaemonProcess $name python-path=$workingPath:$workingPath/env:$workingPath/env/lib/python3.5/site-packages" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo " WSGIProcessGroup $name" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo " WSGIScriptAlias / /var/www/gitwrapper/$name/project/wsgi.py" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo " WSGIScriptAlias / $workingPath/project/wsgi.py" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo " # socket.io conf" >> /etc/apache2/sites-enabled/$name.conf
|
||||
|
||||
echo " <Location '/socket.io'>" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo " RewriteEngine On" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo " RewriteCond %{REQUEST_URI} ^/socket.io/1/websocket [NC]" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo " RewriteRule socket.io/(.*) ws://localhost:$nodePort/socket.io/\$1 [P,L]" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo " ProxyPass http://localhost:$nodePort/socket.io" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo " ProxyPassReverse http://localhost:$nodePort/socket.io" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo " </Location>" >> /etc/apache2/sites-enabled/$name.conf
|
||||
echo "</VirtualHost>" >> /etc/apache2/sites-enabled/$name.conf
|
||||
|
||||
|
||||
service apache2 restart
|
||||
/usr/sbin/service apache2 restart
|
||||
|
||||
exit 0
|
||||
|
@ -5,6 +5,6 @@ sshURL="$2"
|
||||
rm -rf /var/www/gitwrapper/$name
|
||||
rm /etc/apache2/sites-enabled/$name.conf
|
||||
|
||||
service apache2 reload
|
||||
/usr/sbin/service apache2 restart
|
||||
|
||||
exit 0
|
||||
|
9
random_port.py
Executable file
9
random_port.py
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
import socket
|
||||
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.bind(('', 0))
|
||||
addr = s.getsockname()
|
||||
print (addr[1])
|
||||
s.close()
|
||||
exit(0)
|
@ -10,21 +10,24 @@ var install_dir = '/var/www/gitwrapper/'
|
||||
|
||||
var calls = {
|
||||
create: function(req, res, name, sshURL){
|
||||
console.log("create =========================");
|
||||
return exec('bash /var/www/gitdeploy/create.sh '+name+' '+sshURL, function(err, stdout, stderr){
|
||||
|
||||
return res.json({ title: 'Express' });
|
||||
console.log(err, stdout, stderr);
|
||||
return res.json({ title: stdout });
|
||||
});
|
||||
},
|
||||
update: function(req, res, name, sshURL){
|
||||
console.log("update =========================");
|
||||
return exec('bash /var/www/gitdeploy/update.sh '+name+' '+sshURL, function(err, stdout, stderr){
|
||||
|
||||
return res.json({ title: 'Express' });
|
||||
console.log(err, stdout, stderr);
|
||||
return res.json({ title: stdout });
|
||||
});
|
||||
},
|
||||
delete: function(req, res, name, sshURL){
|
||||
console.log("delete =========================");
|
||||
return exec('bash /var/www/gitdeploy/delete.sh '+name+' '+sshURL, function(err, stdout, stderr){
|
||||
|
||||
return res.json({ title: 'Express' });
|
||||
console.log(err, stdout, stderr);
|
||||
return res.json({ title: stdout });
|
||||
});
|
||||
}
|
||||
|
||||
|
21
update.sh
21
update.sh
@ -1,24 +1,37 @@
|
||||
#!/bin/bash
|
||||
name="$1"
|
||||
sshURL="$2"
|
||||
workingPath=/var/www/gitwrapper/$name
|
||||
|
||||
eval "$(ssh-agent -s)"
|
||||
ssh-add /root/.ssh/id_github_rsa
|
||||
cd $workingPath
|
||||
|
||||
|
||||
DJANGO_SETTINGS_MODULE=project.settings.prod
|
||||
export DJANGO_SETTINGS_MODULE=project.settings.prod
|
||||
cd /var/www/gitwrapper/$name
|
||||
|
||||
source env/bin/activate
|
||||
|
||||
git stash
|
||||
git pull --force origin $name
|
||||
pip install -r requirements.txt
|
||||
|
||||
./scripts/setup.sh
|
||||
source env/bin/activate
|
||||
|
||||
python3 manage.py collectstatic --noinput
|
||||
python3 manage.py migrate
|
||||
|
||||
chmod 777 .
|
||||
chmod 777 db.sqlite3
|
||||
service apache2 reload
|
||||
|
||||
echo "starting node app"
|
||||
NODE_ENV='staging'
|
||||
export NODE_ENV='staging'
|
||||
nodePort=cat env/nodePort
|
||||
export NODEPORT=$nodePort
|
||||
forever stop $workingPath/node_rtc/app.js
|
||||
forever start $workingPath/node_rtc/app.js
|
||||
|
||||
/usr/sbin/service apache2 restart
|
||||
|
||||
exit 0
|
||||
|
Reference in New Issue
Block a user