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

Unable to process all rules via launchctl #413

Open
edwilde opened this issue Sep 4, 2024 · 0 comments
Open

Unable to process all rules via launchctl #413

edwilde opened this issue Sep 4, 2024 · 0 comments
Labels

Comments

@edwilde
Copy link

edwilde commented Sep 4, 2024

Describe the bug

This is a weird issue.

I have a config setup which has 2 rules, one is to run a script the other is to find some files and delete them as a cleanup. This works just fine when I manually run organise run from the terminal.

However, when I set the application to run via launchctl then it only processes one of the rules (the script). With no hints as to what happened with the other.

I have tried various things, checked permissions, run as root - always the same, works fine manually, doesn't process as a service. I have tried adding more rules, reordering, and still, the only one which is processed is the script 🤔

Screenshots

This is a recent output from a manual run

edwilde@computer ~/L/A/organize> organize sim
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ SIMULATION                                                                                                                │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Config: "config.yaml"

⚙ Rule #0: Delete old snapshot files ────────────────────────────────────────────────────────────────────────────────────────
/Users/edwilde/Downloads
  ./example.sql
    - (echo) Deleting old snapshot file: /Users/edwilde/Downloads/example.sql
    - (trash) Trash "/Users/edwilde/Downloads/example.sql"

⚙ Rule #1 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
(echo) Running cleanup-test-databases.sh
(shell) ** not run in simulation ** $ /Users/edwilde/Scripts/cleanup-test-databases.sh

success 2 / fail 0
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ SIMULATION                                                                                                                │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Here is the output when run via launchctl

Script started at Thu Sep  5 07:51:18 NZST 2024
Running organize command...
Config: "/Users/edwilde/Library/Application Support/organize/config.yaml"

⚙ Rule #2 ──────────────────────────────────────────────────────────────────────
(echo) Running cleanup-test-databases.sh
(shell) $ /Users/edwilde/Scripts/cleanup-test-databases.sh

success 1 / fail 0
Script ended at Thu Sep  5 07:51:22 NZST 2024

Environment (please complete the following information):

  • OS: macOS 12.7.6, M1
  • Output of organize --version: organize v3.2.5

Your config file

# organize configuration file
# https://organize.readthedocs.io

rules:
  - name: "Delete old snapshot files"
    locations:
      - path: /Users/edwilde/Sites
        max_depth: 3
        exclude_dirs: ["vendor", "node_modules"]
      - path: /Users/edwilde/Downloads
        max_depth: 2
        exclude_dirs: ["vendor", "node_modules"]
    filters:
      - extension:
          - sql
          - sspak
          - sspak.gz
          - sspak.zip
      - lastmodified:
          weeks: 4
      - macos_tags:
          - "Delete soon (red)"
    actions:
      - echo: "Deleting old snapshot file: {path}"
      - trash
  - name: "Clear testing databases"
    actions:
      - echo: "Running cleanup-test-databases.sh"
      - shell: /Users/edwilde/Scripts/cleanup-test-databases.sh

~/Library/LaunchAgents/com.edwilde.organize.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.edwilde.organize.hourly</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/bash</string>
        <string>/Users/edwilde/Library/Application Support/organize/run-organize.sh</string>
    </array>
    <key>StartInterval</key>
    <integer>3600</integer>
    <key>StandardOutPath</key>
    <string>/Users/edwilde/Library/Logs/com.edwilde.organize.hourly.out</string>
    <key>StandardErrorPath</key>
    <string>/Users/edwilde/Library/Logs/com.edwilde.organize.hourly.err</string>
</dict>
</plist>

~/Library/Application Support/organize/run-organize.sh

#!/bin/bash
LOG_FILE="/Users/edwilde/Library/Application Support/organize/run-organize.log"
echo "Script started at $(date)" >> "$LOG_FILE"
echo "Running organize command..." >> "$LOG_FILE"
/opt/homebrew/bin/organize run "/Users/edwilde/Library/Application Support/organize/config.yaml" >> "$LOG_FILE" 2>&1
echo "Script ended at $(date)" >> "$LOG_FILE"
@edwilde edwilde added the bug label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant