Skip to content

Commit

Permalink
Added support for clr20 and clr40 runtimes. Bump to 1.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebakken committed Sep 20, 2012
1 parent 0d9763d commit 2c35180
Show file tree
Hide file tree
Showing 15 changed files with 170 additions and 67 deletions.
15 changes: 15 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto

# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.cs text

# Declare files that will always have CRLF line endings on checkout.
*.csproj text eol=crlf
*.sln text eol=crlf

# Denote all files that are truly binary and should not be modified.
*.exe binary
*.png binary
*.jpg binary
100 changes: 50 additions & 50 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
@echo off

setlocal

set VCVARSALL="C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"

set SLN="%~dp0\IronFoundry.sln"
set VERSION=1.7.1.0

set NOCLEAN=0
if /i "%1"=="NOCLEAN" set NOCLEAN=1

if not exist %VCVARSALL% (
echo Required file %VCVARSALL% not found.
exit 1
)

if not exist %SLN% (
echo Required file %SLN% not found.
exit 1
)

rem Prevent this from being run multiple times on a dev machine
if "%DevEnvDir%"=="" (
call %VCVARSALL% x86
)

if %NOCLEAN% equ 0 (
echo CLEANING...
powershell -nologo -file clean.ps1
echo DONE.
)

msbuild /v:n /t:build /p:Configuration=Debug /p:Platform=x86 %SLN%
if ERRORLEVEL 1 goto build_failed

msbuild /v:n /t:build /p:Configuration=Debug /p:Platform=x64 %SLN%
if ERRORLEVEL 1 goto build_failed

msbuild /v:n /t:build /p:Configuration=Release /p:Platform=x86 /p:WixValues="VERSION=%VERSION%" %SLN%
if ERRORLEVEL 1 goto build_failed

msbuild /v:n /t:build /p:Configuration=Release /p:Platform=x64 /p:WixValues="VERSION=%VERSION%" %SLN%
if ERRORLEVEL 1 goto build_failed

exit /b %ERRORLEVEL%

:build_failed
echo Build failed!
exit /b 1
@echo off

setlocal

set VCVARSALL="C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"

set SLN="%~dp0\IronFoundry.sln"
set VERSION=1.8.0

set NOCLEAN=0
if /i "%1"=="NOCLEAN" set NOCLEAN=1

if not exist %VCVARSALL% (
echo Required file %VCVARSALL% not found.
exit 1
)

if not exist %SLN% (
echo Required file %SLN% not found.
exit 1
)

rem Prevent this from being run multiple times on a dev machine
if "%DevEnvDir%"=="" (
call %VCVARSALL% x86
)

if %NOCLEAN% equ 0 (
echo CLEANING...
powershell -noprofile -nologo -file clean.ps1
echo DONE.
)

msbuild /v:n /t:build /p:Configuration=Debug /p:Platform=x86 %SLN%
if ERRORLEVEL 1 goto build_failed

msbuild /v:n /t:build /p:Configuration=Debug /p:Platform=x64 %SLN%
if ERRORLEVEL 1 goto build_failed

msbuild /v:n /t:build /p:Configuration=Release /p:Platform=x86 /p:WixValues="VERSION=%VERSION%" %SLN%
if ERRORLEVEL 1 goto build_failed

msbuild /v:n /t:build /p:Configuration=Release /p:Platform=x64 /p:WixValues="VERSION=%VERSION%" %SLN%
if ERRORLEVEL 1 goto build_failed

exit /b %ERRORLEVEL%

:build_failed
echo Build failed!
exit /b 1
2 changes: 1 addition & 1 deletion src/IronFoundry.Dea.Service/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Set localRoute to a value other than 127.0.0.1 if you have multiple NICs and are not sending the correct IP to the Nats Host (unlikely)
natsUser and natsPassword attributes must be present even if empty for installer to work.
-->
<ironFoundryDea natsHost="192.168.171.129"
<ironFoundryDea natsHost="10.91.2.37"
natsPort="4222"
natsUser="nats"
natsPassword="nats"
Expand Down
4 changes: 2 additions & 2 deletions src/IronFoundry.Dea/Agent/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private void ProcessDeaStart(string message, string reply)
if (filesManager.Stage(droplet, instance))
{
WebServerAdministrationBinding binding = webServerProvider.InstallWebApp(
filesManager.GetApplicationPathFor(instance), instance.Staged);
filesManager.GetApplicationPathFor(instance), instance.Staged, instance.ManagedRuntimeVersion);
if (null == binding)
{
log.Error(Resources.Agent_ProcessDeaStartNoBindingAvailable, instance.Staged);
Expand Down Expand Up @@ -277,7 +277,7 @@ private void ProcessDeaDiscover(string message, string reply)
log.Debug(Resources.Agent_ProcessDeaDiscover_Fmt, message, reply);

Discover discover = Message.FromJson<Discover>(message);
if (discover.Runtime == Constants.SupportedRuntime)
if (Constants.IsSupportedRuntime(discover.Runtime))
{
uint delay = 0;
dropletManager.ForAllInstances(discover.DropletID, (instance) =>
Expand Down
42 changes: 39 additions & 3 deletions src/IronFoundry.Dea/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,60 @@
namespace IronFoundry.Dea
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;

public static class Constants
{
public const string FilesServiceNamespace = @"http://ironfoundry.org/dea/filesservice";
public const string MonitoringServiceNamespace = @"http://ironfoundry.org/dea/monitoringservice";

public const string SupportedFramework = "aspdotnet";
public const string SupportedRuntime = "aspdotnet40";

public static readonly IPAddress LocalhostIP;

public static int[] MemoryLimits = new int[6] { 64, 128, 256, 512, 1024, 2048 };

private const string localhostStr = "127.0.0.1";

private const string aspDotNetFramework = "aspdotnet";
private static readonly IDictionary<string, ushort> runtimeMap = new Dictionary<string, ushort>
{
{ "aspdotnet40", 4 },
{ "clr20", 2 },
{ "clr40", 4 },
};
private static readonly string[] supportedFrameworks = new[] { aspDotNetFramework };

static Constants()
{
IPAddress.TryParse(localhostStr, out LocalhostIP);
}

public static bool IsSupportedRuntime(string runtime)
{
return (! String.IsNullOrWhiteSpace(runtime)) && runtimeMap.ContainsKey(runtime);
}

public static bool IsSupportedFramework(string framework)
{
return (! String.IsNullOrWhiteSpace(framework)) && supportedFrameworks.Contains(framework);
}

public static string[] SupportedRuntimes
{
get { return runtimeMap.Keys.ToArray(); }
}

public static bool IsAspNet(string framework)
{
return aspDotNetFramework == framework;
}

public static ushort GetManagedRuntimeVersion(string runtime)
{
ushort rv = 0;
runtimeMap.TryGetValue(runtime, out rv);
return rv;
}
}
}
9 changes: 9 additions & 0 deletions src/IronFoundry.Dea/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/IronFoundry.Dea/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,7 @@
<data name="WebServerAdministrationProvider_AppCmdFailed_Fmt" xml:space="preserve">
<value>'appcmd.exe {0}' failed: {1}</value>
</data>
<data name="WebServerAdministrationProvider_InvalidManagedRuntimeVersion_Fmt" xml:space="preserve">
<value>Invalid managed runtime version: {0}</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public class WebServerAdministrationBinding

public interface IWebServerAdministrationProvider
{
WebServerAdministrationBinding InstallWebApp(string localDirectory, string applicationInstanceName);
WebServerAdministrationBinding InstallWebApp(
string localDirectory, string applicationInstanceName, ushort managedRuntimeVersion);
void UninstallWebApp(string applicationInstanceName);
ApplicationInstanceStatus GetApplicationStatus(string applicationInstanceName);
IDictionary<string, IList<int>> GetIIsWorkerProcesses();
Expand Down
13 changes: 10 additions & 3 deletions src/IronFoundry.Dea/Providers/WebServerAdministrationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,17 @@ public WebServerAdministrationProvider(ILog log, IConfig config, IFirewallServic
UnlockLogging();
}

public WebServerAdministrationBinding InstallWebApp(string localDirectory, string applicationInstanceName)
public WebServerAdministrationBinding InstallWebApp(
string localDirectory, string applicationInstanceName, ushort managedRuntimeVersion)
{
WebServerAdministrationBinding rv = null;

if (managedRuntimeVersion != 2 && managedRuntimeVersion != 4)
{
throw new ArgumentException(
String.Format(Resources.WebServerAdministrationProvider_InvalidManagedRuntimeVersion_Fmt, managedRuntimeVersion), "managedRuntimeVersion");
}

try
{
ushort applicationPort = 0;
Expand All @@ -66,8 +73,8 @@ public WebServerAdministrationBinding InstallWebApp(string localDirectory, strin
}

cmd = String.Format(
"set apppool {0} /autoStart:true /managedRuntimeVersion:v4.0 /managedPipelineMode:Integrated /processModel.loadUserProfile:true",
applicationInstanceName);
"set apppool {0} /autoStart:true /managedRuntimeVersion:v{1}.0 /managedPipelineMode:Integrated /processModel.loadUserProfile:true",
applicationInstanceName, managedRuntimeVersion);
rslt = ExecAppcmd(cmd, 5, twoSeconds);
if (false == rslt.Success)
{
Expand Down
4 changes: 1 addition & 3 deletions src/IronFoundry.Dea/Types/Advertise.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

public class Advertise : Message
{
private static readonly string[] runtimes = new[] { Constants.SupportedRuntime };

private const string publishSubject = "dea.advertise";

[JsonIgnore]
Expand All @@ -31,7 +29,7 @@ public override string PublishSubject
[JsonProperty(PropertyName = "runtimes")]
public string[] Runtimes
{
get { return runtimes; }
get { return Constants.SupportedRuntimes; }
}

public Advertise(Guid id, uint availableMemory, ushort currentlyPending, bool ready)
Expand Down
3 changes: 1 addition & 2 deletions src/IronFoundry.Dea/Types/Droplet.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace IronFoundry.Dea.Types
{
using System;
using Newtonsoft.Json;

public class Droplet : EntityBase
Expand Down Expand Up @@ -50,7 +49,7 @@ public class Droplet : EntityBase
[JsonIgnore]
public bool FrameworkSupported
{
get { return false == String.IsNullOrWhiteSpace(Framework) && Framework == Constants.SupportedFramework; }
get { return Constants.IsSupportedFramework(Framework); }
}
}
}
6 changes: 6 additions & 0 deletions src/IronFoundry.Dea/Types/Instance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ public DateTime StartDate
[JsonProperty(PropertyName = "runtime")]
public string Runtime { get; set; }

[JsonIgnore]
public ushort ManagedRuntimeVersion
{
get { return Constants.GetManagedRuntimeVersion(Runtime); }
}

[JsonProperty(PropertyName = "framework")]
public string Framework { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions src/shared/CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
[assembly: AssemblyDescription("https://github.com/IronFoundry/ironfoundry")]
[assembly: AssemblyProduct("Iron Foundry")]
[assembly: AssemblyTrademark("Iron Foundry")]
[assembly: AssemblyFileVersion("1.7.1.0")]
[assembly: AssemblyVersion("1.7.1.0")]
[assembly: AssemblyFileVersion("1.8.0.0")]
[assembly: AssemblyVersion("1.8.0.0")]
29 changes: 29 additions & 0 deletions tools/stop-apps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'json'

file = ARGV[0]
unless not file.nil? and File.exists?(file)
STDERR.puts("File '#{file}' does not exist.")
exit 1
end

j = JSON.load(File.open(file, 'rb:bom|utf-8'))

pids = []

j.each do |user|
email = user['email']
apps = user['apps']
unless apps.nil? or apps.empty?
apps.each do |app|
app_name = app['name']
puts "Stopping user '#{email}' app '#{app_name}' ...\n\n"
STDOUT.flush
pid = Process.spawn("vmc -u #{email} stop #{app_name}")
pids << pid
if pids.length >= 10
Process.waitall()
pids = []
end
end
end
end
Binary file added tools/users.json
Binary file not shown.

0 comments on commit 2c35180

Please sign in to comment.