Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复当路径中含有空格的时候shell执行失败的问题 #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/master/starter.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@ Starter.prototype.prepare = function(main,message,clients){
var count = parseInt(message.agent,10) || 1;
for(var ipindex in clients) {
for (var i = 0;i<count;i++) {
var cmd = 'cd ' + process.cwd() + ' && ' + process.execPath + ' ' + main + ' client > log/.log';
// �޸���·���к��пո��ʱ��shellִ��ʧ�ܵ�����
var fixPath = function (path) {
if (path && path.indexOf(' ') >= 0) {
path = '"' + path + '"';
}
return path;
}
var cwd = fixPath(process.cwd());
var execPath = fixPath(process.execPath);
var fixMain = fixPath(main);
var cmd = 'cd ' + cwd + ' && ' + execPath + ' ' + fixMain + ' client > log/' + i + '.log';
var ip = clients[ipindex];
if (ip==='127.0.0.1') {
self.localrun(cmd);
Expand Down