diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 1140c97..396170a 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.10'] + python-version: ['3.9', '3.13'] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install tox diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml index 38d6920..708472a 100644 --- a/.github/workflows/package.yaml +++ b/.github/workflows/package.yaml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.10'] + python-version: ['3.9', '3.13'] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 9b5a3be..1ea24b6 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -10,9 +10,9 @@ jobs: name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI runs-on: ubuntu-latest steps: - - uses: actions/checkout@master + - uses: actions/checkout@v4 - name: Set up Python 3.9 - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: 3.9 - name: Install dependencies diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f3b2580..133fa64 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,15 +10,16 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.8', '3.11'] + python-version: ['3.9', '3.13'] galaxy-branch: ['release_23.0', 'dev'] exclude: - # this results in lengthy and expensive numpy wheel builds - - python-version: '3.10' - galaxy-branch: 'release_22.01' + # either the release existed before the python release or some expensive-to-build wheels (e.g. numpy) don't + # exist for the pinned package version / python version combo + - python-version: '3.13' + galaxy-branch: 'release_23.0' steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Precreate virtualenv diff --git a/gravity/cli.py b/gravity/cli.py index aaf7257..af99aad 100644 --- a/gravity/cli.py +++ b/gravity/cli.py @@ -83,11 +83,13 @@ def galaxy(ctx, debug, config_file, state_dir, quiet): @options.debug_option() @options.config_file_option() @options.state_dir_option() +@options.user_mode_option() @click.pass_context -def galaxyctl(ctx, debug, config_file, state_dir): +def galaxyctl(ctx, debug, config_file, state_dir, user): """Manage Galaxy server configurations and processes.""" set_debug(debug) ctx.cm_kwargs = { "config_file": config_file, "state_dir": state_dir, + "user_mode": user, } diff --git a/gravity/config_manager.py b/gravity/config_manager.py index d202e82..1b26ece 100644 --- a/gravity/config_manager.py +++ b/gravity/config_manager.py @@ -35,8 +35,8 @@ @contextlib.contextmanager -def config_manager(config_file=None, state_dir=None): - yield ConfigManager(config_file=config_file, state_dir=state_dir) +def config_manager(config_file=None, state_dir=None, user_mode=None): + yield ConfigManager(config_file=config_file, state_dir=state_dir, user_mode=user_mode) class ConfigManager(object): @@ -44,12 +44,13 @@ class ConfigManager(object): gravity_config_section = "gravity" app_config_file_option = "galaxy_config_file" - def __init__(self, config_file=None, state_dir=None): + def __init__(self, config_file=None, state_dir=None, user_mode=None): self.__configs = {} self.state_dir = None if state_dir is not None: # convert from pathlib.Path self.state_dir = str(state_dir) + self.user_mode = user_mode gravity.io.debug(f"Gravity state dir: {state_dir}") diff --git a/gravity/options.py b/gravity/options.py index 1917672..edf9d69 100644 --- a/gravity/options.py +++ b/gravity/options.py @@ -23,6 +23,14 @@ def config_file_option(): ) +def user_mode_option(): + return click.option( + "--user/--no-user", + default=None, + help="Use `systemctl/journalctl --user` (default: automatic depeending on whether run as root)", + ) + + def no_log_option(): return click.option( '--quiet', is_flag=True, default=False, help="Only output supervisor logs, do not include process logs" diff --git a/gravity/process_manager/__init__.py b/gravity/process_manager/__init__.py index b07a3aa..f0fa7bd 100644 --- a/gravity/process_manager/__init__.py +++ b/gravity/process_manager/__init__.py @@ -65,8 +65,8 @@ def decorator(self, *args, instance_names=None, **kwargs): class BaseProcessExecutionEnvironment(metaclass=ABCMeta): - def __init__(self, state_dir=None, config_file=None, config_manager=None, **kwargs): - self.config_manager = config_manager or ConfigManager(state_dir=state_dir, config_file=config_file) + def __init__(self, state_dir=None, config_file=None, config_manager=None, user_mode=None): + self.config_manager = config_manager or ConfigManager(state_dir=state_dir, config_file=config_file, user_mode=user_mode) self.tail = which("tail") @abstractmethod @@ -291,8 +291,8 @@ def exec(self, config, service, service_instance_number=None, no_exec=False): class ProcessManagerRouter: - def __init__(self, state_dir=None, config_file=None, config_manager=None, **kwargs): - self.config_manager = config_manager or ConfigManager(state_dir=state_dir, config_file=config_file) + def __init__(self, state_dir=None, config_file=None, config_manager=None, user_mode=None, **kwargs): + self.config_manager = config_manager or ConfigManager(state_dir=state_dir, config_file=config_file, user_mode=user_mode) self._load_pm_modules(**kwargs) self._process_executor = ProcessExecutor(config_manager=self.config_manager) diff --git a/gravity/process_manager/systemd.py b/gravity/process_manager/systemd.py index efea36d..3d94fe2 100644 --- a/gravity/process_manager/systemd.py +++ b/gravity/process_manager/systemd.py @@ -110,7 +110,9 @@ class SystemdProcessManager(BaseProcessManager): def __init__(self, foreground=False, **kwargs): super(SystemdProcessManager, self).__init__(**kwargs) - self.user_mode = not self.config_manager.is_root + self.user_mode = self.config_manager.user_mode + if self.user_mode is None: + self.user_mode = not self.config_manager.is_root @property def __systemd_unit_dir(self):