mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-04-24 11:45:40 +08:00
finish test for php-fpm
This commit is contained in:
@@ -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 {}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user