Compare commits
34 Commits
teststuff3
...
node
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 |
55
create.sh
55
create.sh
@ -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
|
||||
|
||||
cp /var/www/local_settings.py project/settings/local_settings.py
|
||||
echo "BRANCH = '$name'" >> project/settings/local_settings.py
|
||||
source env/bin/activate
|
||||
|
||||
# set up project from prod, load database
|
||||
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
|
||||
|
||||
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
|
||||
|
@ -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 });
|
||||
|
15
update.sh
15
update.sh
@ -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
|
||||
|
Reference in New Issue
Block a user