55 Commits

Author SHA1 Message Date
0fc95da317 added down message to staging 2017-01-16 17:39:21 -05:00
a495b99bc5 added down message to staging 2017-01-16 17:36:47 -05:00
cca2a255da Merge pull request #12 from wmantly/patch-for-track-dev
Update create.sh
2016-11-15 12:21:41 -05:00
615c347955 Update create.sh 2016-11-15 12:21:31 -05:00
e3fe13246c Update create.sh 2016-11-03 03:05:13 -04:00
634891019e delete 2016-10-11 22:37:46 -04:00
33d066fa39 Merge branch 'master' of https://github.com/wmantly/gitdeploy 2016-10-11 22:30:24 -04:00
ae48b9e715 stop node stuff 2016-10-11 22:29:56 -04:00
81ae2dc1e3 Update update.sh 2016-10-05 04:06:04 -04:00
3577d867d1 Update create.sh 2016-10-05 04:05:37 -04:00
563b252e68 node 2016-10-01 22:12:03 -04:00
f934e1bc70 node 2016-10-01 22:05:11 -04:00
daa9019e02 node 2016-10-01 22:04:37 -04:00
ab00414555 Merge pull request #10 from wmantly/node
node
2016-10-01 22:01:50 -04:00
e119234161 node 2016-10-01 22:01:27 -04:00
df5d98e67a Merge pull request #9 from wmantly/node
node
2016-10-01 21:58:33 -04:00
d85ba96a41 node 2016-10-01 21:58:20 -04:00
f16f300f4b Merge pull request #8 from wmantly/node
node
2016-10-01 21:49:35 -04:00
ca2132f372 node 2016-10-01 21:49:14 -04:00
9a2f17c6c3 Merge pull request #7 from wmantly/node
node
2016-10-01 21:47:02 -04:00
6b280d357a node 2016-10-01 21:46:30 -04:00
9149cfa44d Merge pull request #6 from wmantly/node
node
2016-10-01 21:42:32 -04:00
e974481688 node 2016-10-01 21:42:10 -04:00
0a19f3fd18 Merge pull request #5 from wmantly/node
node
2016-10-01 21:28:50 -04:00
7819cdda0d node 2016-10-01 21:28:24 -04:00
88408fd904 Merge pull request #4 from wmantly/node
node
2016-10-01 21:19:51 -04:00
38a592e29e node 2016-10-01 21:19:17 -04:00
08ec8f8002 Merge pull request #3 from wmantly/node
Node
2016-10-01 18:46:28 -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
4 changed files with 78 additions and 19 deletions

View File

@ -1,52 +1,88 @@
#!/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
export djangoURL="http://$name.staging.bytedev.co"
git clone $sshURL .
echo "creating apache VirtualHost file and showing down"
echo "<VirtualHost *:80>" > /etc/apache2/sites-enabled/$name.conf
echo " ServerName $name.staging.bytedev.co" >> /etc/apache2/sites-enabled/$name.conf
echo " DocumentRoot $workingPath/static/error_pages" >> /etc/apache2/sites-enabled/$name.conf
echo "</VirtualHost>" >> /etc/apache2/sites-enabled/$name.conf
/usr/sbin/service apache2 reload
./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
chmod 777 -R .track-storage
forever stop $workingPath/node_rtc/app.js
echo "starting node app on port $nodePort"
forever start $workingPath/node_rtc/app.js
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 " RewriteEngine On" >> /etc/apache2/sites-enabled/$name.conf
echo " RewriteCond %{HTTP:UPGRADE} ^WebSocket\$ [NC]" >> /etc/apache2/sites-enabled/$name.conf
echo " RewriteCond %{HTTP:CONNECTION} Upgrade\$ [NC]" >> /etc/apache2/sites-enabled/$name.conf
echo " RewriteRule .* ws://localhost:$nodePort%{REQUEST_URI} [P]" >> /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 /socket.io http://localhost:$nodePort/socket.io" >> /etc/apache2/sites-enabled/$name.conf
echo " ProxyPassReverse /socket.io http://localhost:$nodePort/socket.io" >> /etc/apache2/sites-enabled/$name.conf
echo "</VirtualHost>" >> /etc/apache2/sites-enabled/$name.conf
/usr/sbin/service apache2 restart
/usr/sbin/service apache2 reload
exit 0

View File

@ -1,10 +1,17 @@
#!/bin/bash
name="$1"
sshURL="$2"
workingPath=/var/www/gitwrapper/$name
nodePort=`cat $workingPath/env/nodePort`
export NODEPORT=$nodePort
forever stop $workingPath/node_rtc/app.js
rm -rf /var/www/gitwrapper/$name
rm /etc/apache2/sites-enabled/$name.conf
/usr/sbin/service apache2 restart
exit 0

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,16 @@ 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
export djangoURL="http://$name.staging.bytedev.co"
forever stop $workingPath/node_rtc/app.js
forever start $workingPath/node_rtc/app.js
/usr/sbin/service apache2 restart
exit 0