azist / azos

A to Z Sky Operating System / Microservice Chassis Framework
MIT License
213 stars 29 forks source link

systemd - the hgov tries to read from STDIN even with "daemon" pragma #770

Closed itadapter closed 2 years ago

itadapter commented 2 years ago

Re #757

It tries to read from STDIN, this causes systemd flaw

image

itadapter commented 2 years ago

This is not a bug in Azos.

You are running an interactive shell under systemd because of bug in azh entry point in you code:

You need to fix it in you repository where you have i "azh.dll":

public class Program
  {
    public static int Main(string[] args)
    {
      System.Runtime.Loader.AssemblyLoadContext.Default.Resolving += refAssemblyResolver;

      new Azos.Platform.Abstraction.NetCore.NetCore20Runtime();

      var entryPointDir = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
      Environment.CurrentDirectory = entryPointDir;

      var bargs = new BootArgs(args);

      if (bargs.IsGoverned) //<======== this needs to say OR ISDAEMON
        return ApplicationHostProgramBody.GovernedConsoleMain(bargs);
      else
        return ApplicationHostProgramBody.InteractiveConsoleMain(bargs);
    }

    private static Assembly refAssemblyResolver(System.Runtime.Loader.AssemblyLoadContext loadContext, AssemblyName asmName)
      => Assembly.LoadFrom("{0}.dll".Args(asmName.Name));
  }
itadapter commented 2 years ago

Runs as expected: image