34 Commits

Author SHA1 Message Date
e119234161 node 2016-10-01 22:01:27 -04:00
d85ba96a41 node 2016-10-01 21:58:20 -04:00
ca2132f372 node 2016-10-01 21:49:14 -04:00
6b280d357a node 2016-10-01 21:46:30 -04:00
e974481688 node 2016-10-01 21:42:10 -04:00
7819cdda0d node 2016-10-01 21:28:24 -04:00
38a592e29e node 2016-10-01 21:19:17 -04:00
1c3901af27 node 2016-10-01 18:40:55 -04:00
73e46f0ce9 node 2016-10-01 17:32:25 -04:00
560629e5bb node 2016-10-01 16:51:56 -04:00
f1b329b7d7 node 2016-10-01 16:45:27 -04:00
a0811cc7cc node 2016-10-01 16:39:18 -04:00
ea34a46d75 node 2016-10-01 16:22:34 -04:00
b0b73cdb45 node 2016-10-01 16:13:27 -04:00
7be2696c71 node 2016-10-01 16:01:35 -04:00
ece6c19ca3 node 2016-10-01 15:37:05 -04:00
bc1bb7fea2 node 2016-10-01 15:23:01 -04:00
28160bb7eb node 2016-10-01 14:47:51 -04:00
0cfb5e54f9 node 2016-10-01 14:36:30 -04:00
bfba08b1db node 2016-10-01 14:21:34 -04:00
847407beee node 2016-10-01 00:48:22 -04:00
7437a9fe3b node 2016-10-01 00:38:00 -04:00
7fc8010a60 node 2016-10-01 00:34:00 -04:00
2f3dacb569 node 2016-10-01 00:27:46 -04:00
e0963c1c29 node 2016-10-01 00:16:40 -04:00
3a060d5477 asd 2016-09-30 21:55:38 -04:00
994a3297c9 asd 2016-09-30 21:38:10 -04:00
5fef77b61f asd 2016-09-30 20:13:13 -04:00
b1a9be254b asd 2016-09-30 19:43:18 -04:00
f9b14cb38d asd 2016-09-30 19:32:21 -04:00
591d5249cf asd 2016-09-30 19:24:20 -04:00
7f65e0a420 asd 2016-09-30 19:05:42 -04:00
ee40dcc7f6 asd 2016-09-30 19:04:20 -04:00
67a7f77599 stuff 2016-09-30 18:57:12 -04:00
3 changed files with 55 additions and 18 deletions

View File

@ -1,50 +1,73 @@
#!/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
nodePort=`./random_port.py`
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 .
./scripts/setup.sh
source env/bin/activate
cp /var/www/local_settings.py 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
# set up project from prod, load database
echo "checking out to prod for set up"
git checkout prod
./manage.py createcachetable
./manage.py migrate
./manage.py loaddata /var/www/django.json
python3 manage.py createcachetable
python3 manage.py migrate
python3 manage.py loaddata /var/www/django.json
echo "checking out to $name for set up"
git checkout $name
./scripts/setup.sh
# python3 manage.py collectstatic --noinput
./manage.py migrate
python3 manage.py collectstatic --noinput
python3 manage.py migrate
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"
# set up apache vhost
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
/usr/sbin/service apache2 restart

View File

@ -10,18 +10,21 @@ 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){
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){
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){
console.log(err, stdout, stderr);
return res.json({ title: stdout });

View File

@ -1,19 +1,22 @@
#!/bin/bash
name="$1"
sshURL="$2"
workingPath=/var/www/gitwrapper/$name
# set up git to auth
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
source env/bin/activate
cd /var/www/gitwrapper/$name
git stash
git pull --force origin $name
./scripts/setup.sh
source env/bin/activate
python3 manage.py collectstatic --noinput
python3 manage.py migrate
@ -21,6 +24,14 @@ python3 manage.py migrate
chmod 777 .
chmod 777 db.sqlite3
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