TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    triggercmdagent and tcmd are not recognizing changes to commands.json

    General Discussion
    2
    6
    191
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      DarkGreen92
      last edited by

      Hi,

      I've got the tcmd cli tool installed, and I tried installing triggercmdagent (headless, both foreground app and daemon), and either way, it doesn't seem to recognize when I edit the /root/.TRIGGERcmdData/commands.json file. When I run "tcmd --list", it only shows the "Gnome Editor" command that comes by default, and none of the ones I added. I even removed the Gnome Editor command and that one still shows up.

      Restarting triggercmdagent (app or daemon) as well as the machine itself seems to have no effect.

      RussR 1 Reply Last reply Reply Quote 0
      • RussR
        Russ @DarkGreen92
        last edited by Russ

        @DarkGreen92, I'm glad you asked instead of giving up. I don't know what you OS is, but I think it's Linux and not Raspberri Pi.

        I think the commands.json file that your background agent daemon is using is the one in your user's home folder at /home/(your user)/.TRIGGERcmdData/commands.json, not root's home folder.

        Also, the background agent will only process (add/remove/run) your background commands in the commands.json file, not the foreground commands like Gnome Editor.

        When you use tcmd --list, you're listing the commands in your account, not the local commands in your commands.json file. I think it's only listing Gnome Editor because that command got added to your account when you ran the foreground agent once, and entered your token to log it in.

        You could also try running this command to show you which .TRIGGERcmdData folder the daemon is using:

        systemctl status triggercmdagent
        

        There's my output from my Raspberry Pi. It's using the one in /root because that's what the Raspberry Pi agent uses by default. I think you'll see your non-rpi Linux agent using /home/(your user)/.TRIGGERcmdData.

        pi@garagepi:~ $ systemctl status triggercmdagent
        ● triggercmdagent.service - TRIGGERcmd Agent
           Loaded: loaded (/etc/systemd/system/triggercmdagent.service; enabled; vendor preset: enabled)
           Active: active (running) since Thu 2023-07-13 03:17:03 UTC; 10 months 5 days ago
         Main PID: 262 (node)
           CGroup: /system.slice/triggercmdagent.service
                   └─262 node /usr/share/triggercmdagent/app/src/daemon.js --run /root/.TRIGGERcmdData
        

        Russell VanderMey

        D 1 Reply Last reply Reply Quote 0
        • D
          DarkGreen92 @Russ
          last edited by

          @Russ Sorry I didn't specify. I'm running Debian headless inside Proxmox. I think the problem might actually be that the service is repeatedly crashing after start up. When I run doas systemctl status triggercmdagent I get this:

          × triggercmdagent.service - TRIGGERcmd Agent
               Loaded: loaded (/etc/systemd/system/triggercmdagent.service; enabled; preset: enabled)
               Active: failed (Result: start-limit-hit) since Sat 2024-05-18 17:05:02 EDT; 7min ago
             Duration: 389ms
              Process: 2757 ExecStart=/usr/bin/env node /usr/share/triggercmdagent/app/src/daemon.js --run /root/.TRIGGERcmdData (code=exited, status=0/SUCCESS)
             Main PID: 2757 (code=exited, status=0/SUCCESS)
                  CPU: 385ms
          
          May 18 17:05:02 core-services systemd[1]: triggercmdagent.service: Deactivated successfully.
          May 18 17:05:02 core-services systemd[1]: triggercmdagent.service: Scheduled restart job, restart counter is at 6.
          May 18 17:05:02 core-services systemd[1]: Stopped triggercmdagent.service - TRIGGERcmd Agent.
          May 18 17:05:02 core-services systemd[1]: triggercmdagent.service: Start request repeated too quickly.
          May 18 17:05:02 core-services systemd[1]: triggercmdagent.service: Failed with result 'start-limit-hit'.
          May 18 17:05:02 core-services systemd[1]: Failed to start triggercmdagent.service - TRIGGERcmd Agent.
          

          Running

          doas systemctl reset-failed triggercmdagent
          doas systemctl start triggercmdagent
          doas systemctl status triggercmdagent
          

          gives me what I think is the expected output at first:

          ● triggercmdagent.service - TRIGGERcmd Agent
               Loaded: loaded (/etc/systemd/system/triggercmdagent.service; enabled; preset: enabled)
               Active: active (running) since Sat 2024-05-18 17:17:22 EDT; 113ms ago
             Main PID: 2860 (node)
                Tasks: 7 (limit: 2307)
               Memory: 15.7M
                  CPU: 102ms
               CGroup: /system.slice/triggercmdagent.service
                       └─2860 node /usr/share/triggercmdagent/app/src/daemon.js --run /root/.TRIGGERcmdData
          
          

          But then checking status again right after gives me this again:

          × triggercmdagent.service - TRIGGERcmd Agent
               Loaded: loaded (/etc/systemd/system/triggercmdagent.service; enabled; preset: enabled)
               Active: failed (Result: start-limit-hit) since Sat 2024-05-18 17:17:23 EDT; 2s ago
             Duration: 406ms
              Process: 2860 ExecStart=/usr/bin/env node /usr/share/triggercmdagent/app/src/daemon.js --run /root/.TRIGGERcmdData (code=exited, status=0/SUCCESS)
             Main PID: 2860 (code=exited, status=0/SUCCESS)
                  CPU: 388ms
          
          May 18 17:17:22 core-services systemd[1]: triggercmdagent.service: Deactivated successfully.
          May 18 17:17:23 core-services systemd[1]: triggercmdagent.service: Scheduled restart job, restart counter is at 5.
          May 18 17:17:23 core-services systemd[1]: Stopped triggercmdagent.service - TRIGGERcmd Agent.
          May 18 17:17:23 core-services systemd[1]: triggercmdagent.service: Start request repeated too quickly.
          May 18 17:17:23 core-services systemd[1]: triggercmdagent.service: Failed with result 'start-limit-hit'.
          May 18 17:17:23 core-services systemd[1]: Failed to start triggercmdagent.service - TRIGGERcmd Agent.
          

          Do you have any advice on how to fix the crashes?

          RussR 1 Reply Last reply Reply Quote 0
          • RussR
            Russ @DarkGreen92
            last edited by Russ

            @DarkGreen92, I think you could see the error if you run the command the daemon is running:

            node /usr/share/triggercmdagent/app/src/daemon.js --run /root/.TRIGGERcmdData
            

            It looks like it's running as root, so you should be root too when. You run that command.

            I see it's trying to find the agent config in /root/. TRIGGERcmdData so please show me the contents of that.

            It might just need the token to login. You can give it that by creating a token.tkn in that folder, or run node agent.js --console and it should prompt you for it if it's missing.

            Russell VanderMey

            D 1 Reply Last reply Reply Quote 0
            • D
              DarkGreen92 @Russ
              last edited by

              @Russ That seems to have done it! I think my mistake was mostly running it as a standard user. When I switched to root and ran node agent.js --console, it did prompt me to input the token. After that I was able to restart the service and now when I check status, it always shows as active.

              Thanks for your help.

              RussR 1 Reply Last reply Reply Quote 0
              • RussR
                Russ @DarkGreen92
                last edited by

                @DarkGreen92, great. You're welcome. Thank you for your patience.

                Russell VanderMey

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post