mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-04-23 03:10:30 +08:00
强化 mock test
This commit is contained in:
@@ -2,6 +2,7 @@ child_process = require 'child_process'
|
||||
express = require 'express'
|
||||
|
||||
service = require './service'
|
||||
plugin = require '../../core/plugin'
|
||||
|
||||
{requestAuthenticate} = require '../../core/router/middleware'
|
||||
|
||||
@@ -24,5 +25,7 @@ exports.post '/switch', (req, res) ->
|
||||
$set:
|
||||
'attribute.plugin.phpfpm.is_enable': false
|
||||
, ->
|
||||
service.switch req.account, req.body.enable, ->
|
||||
plugin.systemOperate (callback) ->
|
||||
service.switch req.account, req.body.enable, callback
|
||||
, ->
|
||||
res.json {}
|
||||
|
||||
@@ -6,6 +6,8 @@ async = require 'async'
|
||||
tmp = require 'tmp'
|
||||
fs = require 'fs'
|
||||
|
||||
plugin = require '../../core/plugin'
|
||||
|
||||
mAccount = require '../../core/model/account'
|
||||
|
||||
module.exports =
|
||||
@@ -23,26 +25,28 @@ module.exports =
|
||||
callback()
|
||||
|
||||
switch: (account, is_enable, callback) ->
|
||||
callbackback = ->
|
||||
child_process.exec 'sudo service php5-fpm restart', (err) ->
|
||||
throw err if err
|
||||
callback()
|
||||
|
||||
if is_enable
|
||||
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
|
||||
|
||||
child_process.exec "sudo cp #{filepath} /etc/php5/fpm/pool.d/#{account.username}.conf", (err) ->
|
||||
plugin.systemOperate (callback) ->
|
||||
callbackback = ->
|
||||
child_process.exec 'sudo service php5-fpm restart', (err) ->
|
||||
throw err if err
|
||||
callback()
|
||||
|
||||
if is_enable
|
||||
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
|
||||
|
||||
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()
|
||||
else
|
||||
child_process.exec "sudo rm /etc/php5/fpm/pool.d/#{account.username}.conf", ->
|
||||
callbackback()
|
||||
, callback
|
||||
|
||||
widget: (account, callback) ->
|
||||
jade.renderFile path.join(__dirname, 'view/widget.jade'), {account: account}, (err, html) ->
|
||||
|
||||
Reference in New Issue
Block a user