磁盘资源文件限制

This commit is contained in:
jysperm
2014-07-29 02:36:44 +08:00
parent 5e718052aa
commit e043187faf
3 changed files with 19 additions and 4 deletions

View File

@@ -8,10 +8,12 @@ exports.joinPlan = (account, plan, callback) ->
if serviceName in account.attribute.services if serviceName in account.attribute.services
return callback() return callback()
mAccount.update _id: account._id, mAccount.findAndModify _id: account._id, {},
$addToSet: $addToSet:
'attribute.services': serviceName 'attribute.services': serviceName
, -> ,
new: true
, (err, account)->
(plugin.get serviceName).service.enable account, -> (plugin.get serviceName).service.enable account, ->
callback() callback()

View File

@@ -6,7 +6,8 @@ $ ->
if $(@).attr('href') == location.pathname if $(@).attr('href') == location.pathname
$(@).parent().addClass('active') $(@).parent().addClass('active')
$('#logout').click -> $('#logout').click (e) ->
e.preventDefault()
$.post '/account/logout/', {} $.post '/account/logout/', {}
.success -> .success ->
location.reload() location.reload()

View File

@@ -9,7 +9,19 @@ module.exports =
enable: (account, callback) -> enable: (account, callback) ->
child_process.exec "sudo useradd -m -s /bin/bash #{account.username}", (err, stdout, stderr) -> child_process.exec "sudo useradd -m -s /bin/bash #{account.username}", (err, stdout, stderr) ->
throw err if err throw err if err
child_process.exec "sudo usermod -G #{account.username} -a www-data", (err, stdout, stderr) -> async.parallel [
(callback) ->
child_process.exec "sudo usermod -G #{account.username} -a www-data", callback
(callback) ->
soft_limit = (account.attribute.resources_limit.storage * 1024 * 0.8).toFixed()
hard_limit = (account.attribute.resources_limit.storage * 1024 * 1.2).toFixed()
soft_inode_limit = (account.attribute.resources_limit.storage * 64 * 0.8).toFixed()
hard_inode_limit = (account.attribute.resources_limit.storage * 64 * 1.2).toFixed()
child_process.exec "sudo setquota -u #{account.username} #{soft_limit} #{hard_limit} #{soft_inode_limit} #{hard_inode_limit} -a", callback
], (err) ->
throw err if err
callback() callback()
delete: (account, callback) -> delete: (account, callback) ->