plugin.writeConfig

This commit is contained in:
jysperm
2014-07-19 03:14:12 +08:00
parent 765f43005b
commit ec8d739c86
7 changed files with 30 additions and 37 deletions

View File

@@ -1,7 +1,6 @@
child_process = require 'child_process'
service = require './service'
plugin = require '../../core/plugin'
configure = require './configure'
{requestAuthenticate, getParam} = require '../../core/router/middleware'

View File

@@ -1,9 +1,10 @@
child_process = require 'child_process'
jade = require 'jade'
path = require 'path'
tmp = require 'tmp'
fs = require 'fs'
plugin = require '../../core/plugin'
mAccount = require '../../core/model/account'
template =
@@ -36,18 +37,10 @@ module.exports =
user_configure = _.template template.user_configure,
sites: sites_configure
tmp.file
mode: 0o750
, (err, filepath, fd) ->
fs.writeSync fd, user_configure, 0, 'utf8'
fs.closeSync fd
child_process.exec "sudo cp #{filepath} /etc/nginx/sites-enabled/#{account.username}.conf", (err) ->
plugin.writeConfig "/etc/nginx/sites-enabled/#{account.username}.conf", user_configure, ->
child_process.exec 'sudo service nginx reload', (err) ->
throw err if err
child_process.exec 'sudo service nginx reload', (err) ->
throw err if err
callback()
callback()
widget: (account, callback) ->
jade.renderFile path.join(__dirname, 'view/widget.jade'),

View File

@@ -1,7 +1,6 @@
child_process = require 'child_process'
service = require './service'
plugin = require '../../core/plugin'
{assertInService} = require '../../core/router/middleware'
mAccount = require '../../core/model/account'

View File

@@ -23,26 +23,20 @@ module.exports =
callback()
switch: (account, is_enable, callback) ->
callbackback = ->
restartPhpfpm = ->
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
config_content = _.template (fs.readFileSync path.join(__dirname, 'template/fpm-pool.conf')).toString(),
account: account
child_process.exec "sudo cp #{filepath} /etc/php5/fpm/pool.d/#{account.username}.conf", (err) ->
throw err if err
callbackback()
plugin.writeConfig "/etc/php5/fpm/pool.d/#{account.username}.conf", config_content, ->
restartPhpfpm()
else
child_process.exec "sudo rm /etc/php5/fpm/pool.d/#{account.username}.conf", ->
callbackback()
restartPhpfpm()
widget: (account, callback) ->
jade.renderFile path.join(__dirname, 'view/widget.jade'), {account: account}, (err, html) ->