Wires codex bot into deployer.
This commit is contained in:
parent
cc8a860f41
commit
ade08a27fe
|
@ -8,6 +8,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Framework\Core\Core.csproj" />
|
||||
<ProjectReference Include="..\CodexPlugin\CodexPlugin.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace CodexDiscordBotPlugin
|
|||
{
|
||||
public static class CoreInterfaceExtensions
|
||||
{
|
||||
public static RunningContainer DeployMetricsCollector(this CoreInterface ci, DiscordBotStartupConfig config)
|
||||
public static RunningContainer DeployCodexDiscordBot(this CoreInterface ci, DiscordBotStartupConfig config)
|
||||
{
|
||||
return Plugin(ci).Deploy(config);
|
||||
}
|
||||
|
|
|
@ -6,12 +6,13 @@ namespace CodexPlugin
|
|||
{
|
||||
public class CodexDeployment
|
||||
{
|
||||
public CodexDeployment(RunningContainer[] codexContainers, GethDeployment gethDeployment, CodexContractsDeployment codexContractsDeployment, RunningContainer? prometheusContainer, DeploymentMetadata metadata)
|
||||
public CodexDeployment(RunningContainer[] codexContainers, GethDeployment gethDeployment, CodexContractsDeployment codexContractsDeployment, RunningContainer? prometheusContainer, RunningContainer? discordBotContainer, DeploymentMetadata metadata)
|
||||
{
|
||||
CodexContainers = codexContainers;
|
||||
GethDeployment = gethDeployment;
|
||||
CodexContractsDeployment = codexContractsDeployment;
|
||||
PrometheusContainer = prometheusContainer;
|
||||
DiscordBotContainer = discordBotContainer;
|
||||
Metadata = metadata;
|
||||
}
|
||||
|
||||
|
@ -19,6 +20,7 @@ namespace CodexPlugin
|
|||
public GethDeployment GethDeployment { get; }
|
||||
public CodexContractsDeployment CodexContractsDeployment { get; }
|
||||
public RunningContainer? PrometheusContainer { get; }
|
||||
public RunningContainer? DiscordBotContainer { get; }
|
||||
public DeploymentMetadata Metadata { get; }
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Framework\ArgsUniform\ArgsUniform.csproj" />
|
||||
<ProjectReference Include="..\..\Framework\Core\Core.csproj" />
|
||||
<ProjectReference Include="..\..\ProjectPlugins\CodexDiscordBotPlugin\CodexDiscordBotPlugin.csproj" />
|
||||
<ProjectReference Include="..\..\ProjectPlugins\CodexPlugin\CodexPlugin.csproj" />
|
||||
<ProjectReference Include="..\..\Tests\CodexTests\CodexTests.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -101,6 +101,18 @@ namespace CodexNetDeployer
|
|||
[Uniform("public-gethdiscport", "pgdp", "PUBLICGETHDISCPORT", false, "Required if public-testnet is true. Single port number used for Geth's public discovery port.")]
|
||||
public int PublicGethDiscPort { get; set; }
|
||||
|
||||
[Uniform("discord-bot", "dbot", "DISCORDBOT", false, "If true, will deploy discord bot. Default is false.")]
|
||||
public bool DeployDiscordBot { get; set; } = false;
|
||||
|
||||
[Uniform("dbot-token", "dbott", "DBOTTOKEN", false, "Required if discord-bot is true. Discord token used by bot.")]
|
||||
public string DiscordBotToken { get; set; } = string.Empty;
|
||||
|
||||
[Uniform("dbot-servername", "dbotsn", "DBOTSERVERNAME", false, "Required if discord-bot is true. Name of the Discord server.")]
|
||||
public string DiscordBotServerName { get; set; } = string.Empty;
|
||||
|
||||
[Uniform("dbot-adminrolename", "dbotarn", "DBOTADMINROLENAME", false, "Required if discord-bot is true. Name of the Discord role which will have access to admin features.")]
|
||||
public string DiscordBotAdminRoleName { get; set; } = string.Empty;
|
||||
|
||||
public List<string> Validate()
|
||||
{
|
||||
var errors = new List<string>();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using CodexContractsPlugin;
|
||||
using CodexDiscordBotPlugin;
|
||||
using CodexPlugin;
|
||||
using Core;
|
||||
using GethPlugin;
|
||||
|
@ -25,6 +26,7 @@ namespace CodexNetDeployer
|
|||
ProjectPlugin.Load<CodexContractsPlugin.CodexContractsPlugin>();
|
||||
ProjectPlugin.Load<GethPlugin.GethPlugin>();
|
||||
ProjectPlugin.Load<MetricsPlugin.MetricsPlugin>();
|
||||
ProjectPlugin.Load<CodexDiscordBotPlugin.CodexDiscordBotPlugin>();
|
||||
entryPoint = CreateEntryPoint(new NullLog());
|
||||
}
|
||||
|
||||
|
@ -79,7 +81,27 @@ namespace CodexNetDeployer
|
|||
CheckContainerRestarts(startResults);
|
||||
|
||||
var codexContainers = startResults.Select(s => s.CodexNode.Container).ToArray();
|
||||
return new CodexDeployment(codexContainers, gethDeployment, contractsDeployment, metricsService, CreateMetadata(startUtc));
|
||||
|
||||
var deployment = new CodexDeployment(codexContainers, gethDeployment, contractsDeployment, metricsService, null, CreateMetadata(startUtc));
|
||||
var discordBotContainer = DeployDiscordBot(ci, deployment);
|
||||
|
||||
return new CodexDeployment(codexContainers, gethDeployment, contractsDeployment, metricsService, discordBotContainer, CreateMetadata(startUtc));
|
||||
}
|
||||
|
||||
private RunningContainer? DeployDiscordBot(CoreInterface ci, CodexDeployment deployment)
|
||||
{
|
||||
if (!config.DeployDiscordBot) return null;
|
||||
Log("Deploying Discord bot...");
|
||||
|
||||
var rc = ci.DeployCodexDiscordBot(new DiscordBotStartupConfig(
|
||||
name: "discordbot-" + config.DeploymentName,
|
||||
token: config.DiscordBotToken,
|
||||
serverName: config.DiscordBotServerName,
|
||||
adminRoleName: config.DiscordBotAdminRoleName,
|
||||
deployment));
|
||||
|
||||
Log("Discord bot deployed.");
|
||||
return rc;
|
||||
}
|
||||
|
||||
private EntryPoint CreateEntryPoint(ILog log)
|
||||
|
|
Loading…
Reference in New Issue