Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] shutdown/notify: allow for custom implementations #243

Closed
wants to merge 2 commits into from

Commits on Jun 21, 2023

  1. testutil: support empty string cmd args

    FakeCommand allows unit tests to check which command-line arguments
    were passed, by recording a log of calls with their arguments.
    
    The following examples do not work:
    
    1. shutdown -r "+0" ""
    
    2. echo ""
    
    The last argument supplies the wall message, and an empty argument
    is valid. Having this support in place allows code to simply pass
    an empty argument for exec.Command(...).
    
    The issue is that both the argument and command delimiter uses null
    characters, which makes the command split operation split on the
    first occurrence of two null chars, which breaks the examples above.
    
    To add support for this:
    
    - Change the command delimiter from \000\000 => \000\f\n\r
    
    - Update the Calls() function to split the lines correctly.
    flotter committed Jun 21, 2023
    Configuration menu
    Copy the full SHA
    43a5daf View commit details
    Browse the repository at this point in the history
  2. shutdown/notify: allow custom implementations

    The current shutdown and notify logic in pebble is designed with the
    assumption that it will run under systemd, or at least that some
    systemd components, such as shutdown, is installed.
    
    Allow custom flavours of pebble to change the default assumptions.
    
    - The daemon now defines an notification and shutdown interface, and
      configures the default implementation to use systemd.
    
    - The shutdown logic (of which we currently only support reboot) is
      moved to the systemd package, as its based on systemd.
    
    - Two globals daemon.Notify and daemon.Shutdown now provides a way
      to override the defaults.
    flotter committed Jun 21, 2023
    Configuration menu
    Copy the full SHA
    93859bb View commit details
    Browse the repository at this point in the history