Skip to content

Commit

Permalink
[watcher] OK! Fix to permission issues *cross my fingers*
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandro committed Mar 25, 2012
1 parent ae8b708 commit d8c25b4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ var app_start = function (repo_id, callback) {
lib.tear_down_unionfs_chroot(configData.chroot_base, configData.apphome, configData.apprwfolder, configData.appchroot, function (resp) {
lib.setup_unionfs_chroot(configData.chroot_base, configData.apphome, configData.apprwfolder, configData.appchroot, function (resp) {
if (resp === true) {
var cmd = 'cd '+configData.apphome+'; n npm 0.6.12 install node-watcher .; cd ' + configData.appchroot + ' && ulimit -c unlimited -n 65000 -u 100000 -i 1000000 -l 10240 -s 102400 -m 25600 && sudo ' + path.join(config.opt.app_dir, 'scripts', 'chroot_runner.js');
var cmd = 'cd ' + configData.appchroot + ' && ulimit -c unlimited -n 65000 -u 100000 -i 1000000 -l 10240 -s 102400 -m 25600 && sudo ' + path.join(config.opt.app_dir, 'scripts', 'chroot_runner.js');
//console.log(cmd);
exec(cmd, function (error, stdout, stderr) {
if (stdout) {
Expand Down
54 changes: 33 additions & 21 deletions lib/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,41 +355,53 @@ var setup_unionfs_chroot = function (chroot_base, git_home, rw_folder, final_chr
exports.node_versions = node_versions;

var watcher_code = function(user,pass){
return "(new (require('node-watcher'))({host:'nodester.com',user:'"+user + "',password:'"+ pass+"',path:'/app/audit'})).emitter({maxMemory:25,sizeSpace:25,checkSpace:true})"
return "(new (require('node-watcher'))({host:'http://nodester.com',user:'"+user + "',password:'"+ pass+"',path:'/app/audit'})).emitter({maxMemory:25,sizeSpace:25,checkSpace:true})"
}
exports.watcher_code = watcher_code;

var insert_code = function(location,file,code, cb){
if (path.extname(path.join(location,file)) === '.js'){
var target = path.join(location,file);
try {
var old = fs.readFileSync(target, 'utf8');
var newfile ='';
old = old.split('\n').filter(function(line){
return line !== code;
}).join('\n');
var lines = old.split('\n');
if (/\#!\//gi.test(lines[0])){
var shebang = lines[0]
lines.shift();
newfile = shebang+'\n'+code+'\n'+lines.join('\n');
} else {
newfile = code+'\n'+old
}
var inserted = fs.createWriteStream(target, {'flags': 'w'},'utf8');
inserted.end(newfile);
exec('cd '+location+'; sudo git add .;sudo git commit -am "[nodester] Watcher code inserted"',function(e,d){
if (e) console.log(e);
})
return fs.truncate(fd, len, callback);
exec([
'sudo chown -R nodester '+ location,
'cd '+ location].join('; '),function(err,stdout,stderr){
if (!err){
var old = fs.readFileSync(target, 'utf8');
var newfile ='';
old = old.split('\n').filter(function(line){
return line !== code;
}).join('\n');gi
var lines = old.split('\n');
if (/\#!\//gi.test(lines[0])){
var shebang = lines[0]
lines.shift();
newfile = shebang+'\n'+code+'\n'+lines.join('\n');
} else {
newfile = code+'\n'+old
}
var inserted = fs.createWriteStream(target, {'flags': 'w'},'utf8');
inserted.end(newfile);
exec([
'cd '+ location,
'n npm 0.6.12 install node-watcher .'
'sudo git add .',
'sudo git commit -am "[nodester] Watcher code inserted"',
'sudo chown -R git '+location].join('; '),function(error,stdout2){
if (error) throw error;
});
} else {
throw err;
}
});
return true;
}catch (e){
console.log(e);
return false;
}
} else {
return false;
}

}

exports.insert_code = insert_code;

0 comments on commit d8c25b4

Please sign in to comment.