Difference between revisions of "Limit Service's Disk Space"
Line 25: | Line 25: | ||
**Description: Specify the disk quota in MB. Set to 0 for unlimited space. | **Description: Specify the disk quota in MB. Set to 0 for unlimited space. | ||
**Decimal Digits: 0 | **Decimal Digits: 0 | ||
+ | |||
+ | * '''Configure the scripts.''' Go back to the game's main settings. Click on the Custom Scripts icon. Configure the following scripts. | ||
+ | |||
+ | '''Operating System:''' Any | ||
+ | '''Description:''' Create disk quota when game server is created | ||
+ | '''Script Engine:''' IronPython | ||
+ | '''Event:''' After created | ||
+ | '''Script:''' | ||
+ | |||
+ | import clr; | ||
+ | import System; | ||
+ | from System import UInt64, String, Exception; | ||
+ | |||
+ | diskquotamb = ThisService.Variables["DiskQuota"]; | ||
+ | serviceuser = ThisService.GetServiceCredentials().User; | ||
+ | mountpoint = ThisServer.FileSystemService.GetMountPoint(ThisService.RootDirectory); | ||
+ | |||
+ | if not ThisServer.FileSystemService.QuotasEnabled(ThisService.RootDirectory) : | ||
+ | raise Exception(String.Format("Disk quotas are not enabled on {0}", mountpoint)); | ||
+ | |||
+ | Script.WriteToConsole(String.Format("Creating {0}MB disk quota on {1} for {2}", diskquotamb, mountpoint, serviceuser)); | ||
+ | |||
+ | ThisServer.FileSystemService.SetQuota(serviceuser, mountpoint, UInt64.Parse(diskquotamb) * 1024 * 1024); |
Revision as of 19:51, 24 February 2015
Configure disk quotas in your drive
Linux
- Follow these instructions to configure disk quotas on Linux: Linux_Quotas
Windows
- Enable quotas on the drive where the services will be created. The configuration shown in the screenshot is recommended.
Configure the game
- Configure the game with Run As = User per Service. Go to Settings > Games > select the game > Select the "Run As" tab. Set Run As = User per service and save. This will create one Windows/Linux user for each service. The disk quota will be created for this user.
If you have existing services of this type go to Settings > Game Tools and run the Verify/Repair tool on your server with "Update run as user" checked.
- Configure a variable for the quota value. Click on the Variables icon. Click on new and enter these values:
- Name: DiskQuota
- Default value: 0
- Is numeric: Checked
- Preserve value: Checked
- Select the Variable Options tab and configure these values:
- Script parameter: Checked
- Save script parameter value: Checked
- Admin access: Checked
- Value is required: Checked
- Item Type: Numeric textbox
- Label: Disk Quota (MB)
- Description: Specify the disk quota in MB. Set to 0 for unlimited space.
- Decimal Digits: 0
- Configure the scripts. Go back to the game's main settings. Click on the Custom Scripts icon. Configure the following scripts.
Operating System: Any Description: Create disk quota when game server is created Script Engine: IronPython Event: After created Script:
import clr; import System; from System import UInt64, String, Exception; diskquotamb = ThisService.Variables["DiskQuota"]; serviceuser = ThisService.GetServiceCredentials().User; mountpoint = ThisServer.FileSystemService.GetMountPoint(ThisService.RootDirectory); if not ThisServer.FileSystemService.QuotasEnabled(ThisService.RootDirectory) : raise Exception(String.Format("Disk quotas are not enabled on {0}", mountpoint)); Script.WriteToConsole(String.Format("Creating {0}MB disk quota on {1} for {2}", diskquotamb, mountpoint, serviceuser)); ThisServer.FileSystemService.SetQuota(serviceuser, mountpoint, UInt64.Parse(diskquotamb) * 1024 * 1024);