Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 86 additions & 86 deletions installer/License.rtf

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions src/ServicePulse.Host/Commands/AbstractCommand.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
namespace ServicePulse.Host.Commands
{
using System.IO;
using System.Text.RegularExpressions;
using Hosting;
internal abstract class AbstractCommand
{
public abstract void Execute(HostArguments args);
public static void UpdateConfig(string directoryPath, string serviceControlUrl)
{
var appJsPath = Path.Combine(directoryPath, "config.js");
var appJsCode = File.ReadAllText(appJsPath);
File.WriteAllText(appJsPath,
Regex.Replace(appJsCode, @"(service_control_url: ')([\w:/]*)(')", "$1" + serviceControlUrl + "$3"));
}
}
namespace ServicePulse.Host.Commands
{
using System.IO;
using System.Text.RegularExpressions;
using Hosting;

internal abstract class AbstractCommand
{
public abstract void Execute(HostArguments args);

public static void UpdateConfig(string directoryPath, string serviceControlUrl)
{
var appJsPath = Path.Combine(directoryPath, "config.js");
var appJsCode = File.ReadAllText(appJsPath);
File.WriteAllText(appJsPath,
Regex.Replace(appJsCode, @"(service_control_url: ')([\w:/]*)(')", "$1" + serviceControlUrl + "$3"));
}
}
}
48 changes: 24 additions & 24 deletions src/ServicePulse.Host/Commands/CommandRunner.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
namespace ServicePulse.Host.Commands
{
using System;
using System.Collections.Generic;
using Hosting;
internal class CommandRunner
{
public CommandRunner(List<Type> commands)
{
this.commands = commands;
}
public void Execute(HostArguments args)
{
foreach (var commandType in commands)
{
var command = (AbstractCommand)Activator.CreateInstance(commandType);
command.Execute(args);
}
}
readonly List<Type> commands;
}
namespace ServicePulse.Host.Commands
{
using System;
using System.Collections.Generic;
using Hosting;

internal class CommandRunner
{
public CommandRunner(List<Type> commands)
{
this.commands = commands;
}

public void Execute(HostArguments args)
{
foreach (var commandType in commands)
{
var command = (AbstractCommand)Activator.CreateInstance(commandType);
command.Execute(args);
}
}

readonly List<Type> commands;
}
}
90 changes: 45 additions & 45 deletions src/ServicePulse.Host/Commands/ExtractCommand.cs
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
namespace ServicePulse.Host.Commands
{
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Hosting;
internal class ExtractCommand : AbstractCommand
{
public override void Execute(HostArguments args)
{
ExtractResources(args.OutputPath);
if (String.IsNullOrEmpty(args.ServiceControlUrl))
{
return;
}
UpdateConfig(args.OutputPath, args.ServiceControlUrl);
}
static void ExtractResources(string directoryPath)
{
var assembly = Assembly.GetExecutingAssembly();
var resources = assembly.GetManifestResourceNames().Where(x => x.StartsWith(@"app\"));
foreach (var resourceName in resources)
{
using (var resourceStream = assembly.GetManifestResourceStream(resourceName))
{
var fileName = resourceName.Replace(@"app\", String.Empty);
var destinationPath = Path.Combine(directoryPath, fileName);
Console.WriteLine("Unpacking '{0}' to '{1}'...", fileName, destinationPath);
Directory.CreateDirectory(Path.GetDirectoryName(destinationPath));
using (Stream file = File.OpenWrite(destinationPath))
{
resourceStream.CopyTo(file);
file.Flush();
}
}
}
}
}
namespace ServicePulse.Host.Commands
{
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Hosting;

internal class ExtractCommand : AbstractCommand
{
public override void Execute(HostArguments args)
{
ExtractResources(args.OutputPath);

if (String.IsNullOrEmpty(args.ServiceControlUrl))
{
return;
}

UpdateConfig(args.OutputPath, args.ServiceControlUrl);
}

static void ExtractResources(string directoryPath)
{
var assembly = Assembly.GetExecutingAssembly();
var resources = assembly.GetManifestResourceNames().Where(x => x.StartsWith(@"app\"));
foreach (var resourceName in resources)
{
using (var resourceStream = assembly.GetManifestResourceStream(resourceName))
{
var fileName = resourceName.Replace(@"app\", String.Empty);
var destinationPath = Path.Combine(directoryPath, fileName);
Console.WriteLine("Unpacking '{0}' to '{1}'...", fileName, destinationPath);

Directory.CreateDirectory(Path.GetDirectoryName(destinationPath));

using (Stream file = File.OpenWrite(destinationPath))
{
resourceStream.CopyTo(file);
file.Flush();
}
}
}
}
}
}
52 changes: 26 additions & 26 deletions src/ServicePulse.Host/Commands/InstallCommand.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
namespace ServicePulse.Host.Commands
{
using System;
using System.Collections;
using Hosting;
internal class InstallCommand : ServiceCommand
{
public InstallCommand() : base(installer => installer.Install(new Hashtable()))
{
}
public override void Execute(HostArguments args)
{
if (IsServiceInstalled(args.ServiceName))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Out.WriteLine("The '{0}' service is already installed.", args.ServiceName);
Console.ResetColor();
return;
}
ExecuteInternal(args);
}
}
namespace ServicePulse.Host.Commands
{
using System;
using System.Collections;
using Hosting;

internal class InstallCommand : ServiceCommand
{
public InstallCommand() : base(installer => installer.Install(new Hashtable()))
{
}

public override void Execute(HostArguments args)
{
if (IsServiceInstalled(args.ServiceName))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Out.WriteLine("The '{0}' service is already installed.", args.ServiceName);
Console.ResetColor();

return;
}

ExecuteInternal(args);
}
}
}
52 changes: 26 additions & 26 deletions src/ServicePulse.Host/Commands/RunCommand.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
namespace ServicePulse.Host.Commands
{
using System;
using System.Diagnostics;
using Hosting;
internal class RunCommand : AbstractCommand
{
public override void Execute(HostArguments args)
{
using (var service = new Host(args))
{
service.Run();
if (!Environment.UserInteractive)
{
return;
}
Process.Start(args.Url);
Console.WriteLine("Running on {0}", args.Url);
Console.WriteLine("Press enter to exit");
Console.ReadLine();
}
}
}
namespace ServicePulse.Host.Commands
{
using System;
using System.Diagnostics;
using Hosting;

internal class RunCommand : AbstractCommand
{
public override void Execute(HostArguments args)
{
using (var service = new Host(args))
{
service.Run();

if (!Environment.UserInteractive)
{
return;
}

Process.Start(args.Url);
Console.WriteLine("Running on {0}", args.Url);
Console.WriteLine("Press enter to exit");
Console.ReadLine();
}
}
}
}
Loading