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

Add --replace-all option for development #751

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Commits on Dec 27, 2023

  1. Fix quit dbus action for the GUI

    This action was registered, but did not work because the handler
    accepted too few arguments and also called itself recursively.
    
    This fixes both, calling the 'quit' action (as exposed through dbus by
    gtk automatically) now actually quits the GUI.
    matthijskooijman committed Dec 27, 2023
    Configuration menu
    Copy the full SHA
    e58e609 View commit details
    Browse the repository at this point in the history
  2. hamster-cli: Flatten commandline handling flow

    This simplifies the flow a bit by putting the handling of "add" with
    arguments at the same level of all other application actions instead of
    below it, needing one fewer level of indentation.
    
    Behavior should be fully unchanged. Diff best viewed while ignoring
    whitespace changes.
    matthijskooijman committed Dec 27, 2023
    Configuration menu
    Copy the full SHA
    76bed1d View commit details
    Browse the repository at this point in the history
  3. Print "hamster-service up" later and use logger

    This logs the message after the storage class was actually instantiated
    and registered on the bus, rather than before.
    matthijskooijman committed Dec 27, 2023
    Configuration menu
    Copy the full SHA
    4e78ca6 View commit details
    Browse the repository at this point in the history
  4. hamster-windows-service: Use logger

    This converts the single print in this script to use a logger instance
    (like hamster-service already uses).
    matthijskooijman committed Dec 27, 2023
    Configuration menu
    Copy the full SHA
    3a5aacf View commit details
    Browse the repository at this point in the history
  5. Fix dbus name claiming race condition

    This refactors the way that dbus names are claimed for hamster-service
    and hamster-window-service. Instead of checking if the name is already
    claimed beforehand, this tries to claim the and checks the result.
    
    This fixes a minor race condition when a service is started twice at the
    same time. Before, the name would appear to be free when it was checked,
    but when the script proceeded to actually claim the name, it could have
    been claimed by another instance already. Because do_not_queue was not
    yet used, this means that the claim would probably not even fail, but
    leave a pointless process running.
    
    This commit refactors the code structure to introduce a claim_bus_name
    helper, which claims the name with do_not_queue=True so it either
    fails when the name is already taken, or is sure the name is claimed.
    
    This also raises the bus claiming code out of the Storage and
    WindowServer classes into the main script, since that is a better place
    to decide to abort startup and log messages about this.
    
    This refactoring also prepares for implementing a `--replace` option in
    a subsequent commit.
    matthijskooijman committed Dec 27, 2023
    Configuration menu
    Copy the full SHA
    0fbd1ad View commit details
    Browse the repository at this point in the history
  6. Implement --replace option for all three binaries

    This makes them replace any currently running GUI, storage service or
    windows service. This is primarily useful during development, to prevent
    having to kill these services manually.
    
    For the two services, this is implemented properly by trying to claim
    the bus name and if it is taken, calling the quit method on the current
    instance while the existing claim is kept in the dbus request queue.
    This ensures that as soon as the name is released, it is claimed again
    by the new process (preventing a race condition where a service
    autostart could occur in between).
    
    For the GUI, this race condition is not prevented due to the way
    Gtk/Gio.Application claims its name, but this should be minor enough an
    issue to not be problematic (especially since the user can always easily
    quit the GUI manually beforehand).
    
    This commit implements most of projecthamster#746.
    matthijskooijman committed Dec 27, 2023
    Configuration menu
    Copy the full SHA
    3a22d3b View commit details
    Browse the repository at this point in the history
  7. Remove .py extension from main scripts

    This makes the filenames equal to the name they get when installed,
    which is more consistent and makes it easier to call them
    programmatically (this prepares for implementing `--replace-all` in
    subsequent commit).
    
    The .py extension was added in commit 774c315 (give .py extension to
    hamster-*), on account of letting xgettext understand these are python
    files. Currently, there is no working (or at least not documented)
    xgettext flow anyway, and xgettext seems to support passing an explicit
    language parameter, so this can probably be used, removing the need for
    these explicit extensions.
    matthijskooijman committed Dec 27, 2023
    Configuration menu
    Copy the full SHA
    fca47a2 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    eee3c1c View commit details
    Browse the repository at this point in the history
  9. Revert "Remove .py extension from main scripts"

    This reverts commit 767f80a22593757aec10b3f6ab3a4ef3ab8a0809.
    matthijskooijman committed Dec 27, 2023
    Configuration menu
    Copy the full SHA
    db55ab6 View commit details
    Browse the repository at this point in the history
  10. Detach/daemonize service processes

    This lets the service commands (hamster-service and
    hamster-windows-service) daemonize after initialization. This ensures
    they are detached from their parent process, and allows a caller to wait
    for them to return to know whether startup succeeded or not.
    matthijskooijman committed Dec 27, 2023
    Configuration menu
    Copy the full SHA
    e5ba311 View commit details
    Browse the repository at this point in the history
  11. Implement --replace-all option

    This replaces the GUI and two background services (by using the
    recently added `--replace` options). This is helpful during development
    to easily replace the existing deamons (even when installed system-wide)
    with a development version, without having to resort to fragile pkill
    commands.
    
    This also updates the README to recommend using this option instead of
    kill commands. This also removes a note about not calling windows via
    dbus, since that does not seem to be true with the current codebase.
    
    This fixes projecthamster#746
    matthijskooijman committed Dec 27, 2023
    Configuration menu
    Copy the full SHA
    4109d79 View commit details
    Browse the repository at this point in the history