first
This commit is contained in:
parent
b58deaaa86
commit
b54d5533c9
2
bin/www
2
bin/www
@ -12,7 +12,7 @@ var http = require('http');
|
|||||||
* Get port from environment and store in Express.
|
* Get port from environment and store in Express.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var port = normalizePort(process.env.PORT || '3180');
|
var port = normalizePort(process.env.PORT || '3000');
|
||||||
app.set('port', port);
|
app.set('port', port);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
38
routes/create.sh
Normal file
38
routes/create.sh
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
name="$1"
|
||||||
|
sshURL="$2"
|
||||||
|
|
||||||
|
eval "$(ssh-agent -s)"
|
||||||
|
ssh-add /root/.ssh/github_rsa
|
||||||
|
cd /var/www/gitwrapper
|
||||||
|
mkdir $name
|
||||||
|
cd $name
|
||||||
|
|
||||||
|
git clone $sshURL .
|
||||||
|
git checkout $name
|
||||||
|
virtual env
|
||||||
|
source env/bin/activate
|
||||||
|
pip3 install -r /var/www/gitwrapper/requirements.txt > /var/www/pipinstall.log
|
||||||
|
DJANGO_SETTINGS_MODULE=project.settings.prod
|
||||||
|
export DJANGO_SETTINGS_MODULE=project.settings.prod
|
||||||
|
cp /var/www/local_settings.py project/
|
||||||
|
echo "BRANCH = /"$name/"" >> project/local_settings.py
|
||||||
|
|
||||||
|
python3 manage.py loaddata /var/www/django.dump
|
||||||
|
python3 manage.py collectstatic --noinput
|
||||||
|
python3 manage.py migrate
|
||||||
|
chmod 777 .
|
||||||
|
chmod 777 db.sqlite3
|
||||||
|
|
||||||
|
echo '<VirtualHost *:80>' > /etc/apache2/sites-enabled/runner.conf
|
||||||
|
echo ' Alias /static /var/www/gitwrapper/$name/staticfiles' > /etc/apache2/sites-enabled/runner.conf
|
||||||
|
echo ' WSGIDaemonProcess $name python-path=/var/www/gitwrapper/$name:/var/www/gitwrapper/$name/env/lib/python3.4/site-packages' >> /etc/apache2/sites-enabled/runner.conf
|
||||||
|
echo ' WSGIProcessGroup $name' >> /etc/apache2/sites-enabled/runner.conf
|
||||||
|
echo ' WSGIScriptAlias / /var/www/gitwrapper/$name/project/wsgi.py' >> /etc/apache2/sites-enabled/runner.conf
|
||||||
|
echo '</VirtualHost>' >> /etc/apache2/sites-enabled/runner.conf
|
||||||
|
|
||||||
|
|
||||||
|
service apache2 restart
|
||||||
|
|
||||||
|
# copy and make data base
|
@ -2,14 +2,62 @@ var express = require('express');
|
|||||||
var router = express.Router();
|
var router = express.Router();
|
||||||
var exec = require('child_process').exec;
|
var exec = require('child_process').exec;
|
||||||
/* GET home page. */
|
/* GET home page. */
|
||||||
|
|
||||||
|
var install_dir = '/var/www/gitwrapper/'
|
||||||
|
|
||||||
|
// var shell = {
|
||||||
|
// clone: function(name, sshURL, callback){
|
||||||
|
// return exec('git clone '+ sshURL + ' '+ install_dir + name, function(err, stdout, stderr){
|
||||||
|
// return callback(name, stdout);
|
||||||
|
// },
|
||||||
|
// setUpENV: function(){
|
||||||
|
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
var calls = {
|
||||||
|
create: function(name, sshURL){
|
||||||
|
exec('git clone '+ sshURL + ' /var/www/gitwrapper/'+ name, function(err, stdout, stderr){
|
||||||
|
// set up virtual env
|
||||||
|
// install req file
|
||||||
|
// sync db
|
||||||
|
// run migrations
|
||||||
|
// write apache file
|
||||||
|
// reload apache
|
||||||
|
});
|
||||||
|
},
|
||||||
|
update: function(name, sshURL){
|
||||||
|
// git pull
|
||||||
|
// run migrations
|
||||||
|
// install req file
|
||||||
|
// reload apache
|
||||||
|
},
|
||||||
|
delete: function(name){
|
||||||
|
// delete dir
|
||||||
|
// remove apache file
|
||||||
|
// reload apache
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
router.all('/', function(req, res, next) {
|
router.all('/', function(req, res, next) {
|
||||||
if(req.headers['x-github-event'] === 'push'){
|
var event = req.headers['x-github-event'];
|
||||||
|
var call = (req.body.created && 'create') || (req.body.deleted && 'delete') || 'update';
|
||||||
|
|
||||||
|
var name = req.body.ref.replace('refs/heads/', '');
|
||||||
|
var sshURL = req.body.repository.ssh_url;
|
||||||
|
exec('pwd', console.log);
|
||||||
|
console.log('call', call, 'event:', event, 'name:', name, 'sshURL:', sshURL)
|
||||||
|
// console.log("\n=================\n\n", req.body);
|
||||||
|
/* if(req.headers['x-github-event'] === 'push'){
|
||||||
if(req.body.ref === "refs/heads/master"){
|
if(req.body.ref === "refs/heads/master"){
|
||||||
console.log('time to update master!');
|
console.log('time to update master!');
|
||||||
exec('/var/www/gitwrapperdeploy.sh', console.log, console.log);
|
exec('/var/www/gitwrapperdeploy.sh', console.log, console.log);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
res.render('index', { title: 'Express' });
|
res.json({ title: 'Express' });
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user