finish test for php-fpm

This commit is contained in:
jysperm
2014-05-27 07:59:44 +08:00
parent 6064515ad9
commit 12d960f73c
3 changed files with 16 additions and 20 deletions

View File

@@ -18,13 +18,11 @@ exports.use (req, res, next) ->
exports.post '/switch', (req, res) ->
unless req.body.enable in [true, false]
return res.err 'invalid_enable'
return res.error 'invalid_enable'
mAccount.update _id: account._id,
mAccount.update _id: req.account._id,
$set:
'attribute.plugin.phpfpm.is_enable': false
, ->
callback()
service.switch req.account, req.body.enable, ->
res.json {}

View File

@@ -24,26 +24,22 @@ module.exports =
switch: (account, is_enable, callback) ->
callbackback = ->
child_process.exec 'service php5-fpm restart', ->
child_process.exec 'sudo service php5-fpm restart', (err) ->
throw err if err
callback()
if is_enable
async.series [
(callbacl) ->
tmp.file
mode: 0o750
, (err, filepath, fd) ->
config_content = _.template (fs.readFileSync path.join(__dirname, 'template/fpm-pool.conf')).toString(),
account: account
fs.writeSync fd, config_content, 0, 'utf8'
fs.closeSync fd
callback()
tmp.file
mode: 0o750
, (err, filepath, fd) ->
config_content = _.template (fs.readFileSync path.join(__dirname, 'template/fpm-pool.conf')).toString(),
account: account
fs.writeSync fd, config_content, 0, 'utf8'
fs.closeSync fd
(callback) ->
child_process.exec "sudo cp #{filepath} /etc/php5/fpm/pool.d/#{account.username}.conf", ->
callback()
], ->
callbackback()
child_process.exec "sudo cp #{filepath} /etc/php5/fpm/pool.d/#{account.username}.conf", (err) ->
throw err if err
callbackback()
else
child_process.exec "sudo rm /etc/php5/fpm/pool.d/#{account.username}.conf", ->
callbackback()