Skip to main content
Home
for DLMS smart meters

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Agent In Docker

Agent in docker

By thiesens, 30 September, 2024
Forums
Gurux.DLMS.AMI

Hi Gurux.

Will you be adding a version of the agent, to run in docker?

/Henrik

thiesens

7 months 3 weeks ago

was thinking: Add params to…

was thinking:

Add params to class:

static string serverName = Environment.GetEnvironmentVariable("GURUX_SERVER") ?? "https://localhost:8001";
static string hostName = Environment.GetEnvironmentVariable("GURUX_HOST") ?? System.Net.Dns.GetHostName();
static string token = Environment.GetEnvironmentVariable("GURUX_TOKEN");

Change the RegisterAgent:

public static async Task RegisterAgent(
IServiceCollection services,
AutoResetEvent newVersion,
IGXAgentWorker worker,
AgentOptions options)
{
string name = hostName ?? System.Net.Dns.GetHostName();
if (string.IsNullOrEmpty(token))
{
Console.WriteLine("Running on host. Collecting params");
// string name = System.Net.Dns.GetHostName();
Console.WriteLine("Welcome to use Gurux.DLMS.AMI.");
Console.WriteLine(string.Format("Gurux.DLMS.AMI address: [{0}]", options.Address));
string? tmp = Console.ReadLine();
if (!string.IsNullOrEmpty(tmp))
{
options.Address = tmp;
}
Console.WriteLine(string.Format("Enter agent name: [{0}]", name));
tmp = Console.ReadLine();
if (!string.IsNullOrEmpty(tmp))
{
name = tmp;
}
Console.WriteLine("Enter Personal Access Token:");
options.Token = Console.ReadLine();
if (options.Token == null || options.Token.Length != 64)
{
throw new ArgumentException("Invalid token.");
}
}
else
{
Console.WriteLine("Running in a container.");
options.Address = serverName;
name = hostName;
options.Token = token;
}

worker.Init(services, options, newVersion);
options.Id = await worker.AddAgentAsync(name);
if (options.Id == Guid.Empty)
{
throw new ArgumentException("Invalid agent Id.");
}
File.WriteAllText(settingsFile, JsonSerializer.Serialize(options));
Console.WriteLine("Connection succeeded.");
}

Add a dockerfile, and run it with the 3 env variables.

Profile picture for user Kurumi

Kurumi

7 months 3 weeks ago

Hi Henrik, Yes, this is…

Hi Henrik,

Yes, this is possible. The new Gurux.DLMS.AMI tests start next week. I'll check if it is possible to add this before the next version is released, but it's coming latest with the new version.

BR,
Mikko

thiesens

7 months 3 weeks ago

Perfect Mikke. Looking…

Perfect Mikke.

Looking forward to this.

  • Log in or register to post comments
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 05/20/2025 - 08:40
    gurux.dlms.c 9.0.2505.2001
  • Mon, 05/19/2025 - 10:19
    gurux.net.java 1.0.30
  • Mon, 05/19/2025 - 10:00
    gurux.dlms.c 9.0.2505.1901
  • Thu, 05/15/2025 - 16:26
    gurux.dlms.c 9.0.2505.1501
  • Wed, 05/14/2025 - 08:30
    gurux.dlms.c 9.0.2505.1401

New forum topics

  • HDLC Adress resolver configuration
  • Reading all "Data" object type parameter together
  • com_read getting failed for billing profile and instantaneous profile
  • Simulator connection closed
  • Regarding the dlms android project
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin