Launchd plist running a bash script that calls a node process is exiting with status code 8

StackOverflow https://stackoverflow.com/questions/21611276

  •  08-10-2022
  •  | 
  •  

Domanda

Here is my launchd playlist

   <?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.blockjunk.server.plist</string>
        <key>ProgramArguments</key>
        <array>
          <string>/Users/jeff/scripts/nojunkweb/startserver.sh</string>
        </array>
        <key>RunAtLoad</key>
          <true/>
        <key>KeepAlive</key>
          <true/>
    </dict>
    </plist>

And here is startserver.sh that it is calling

#!/bin/bash

echo "Attempting to start node server"
/usr/local/bin/node /Users/jeff/scripts/nojunkweb/server.js "http://dynamic.xkcd.com/random/comic/" "https://www.shortcutfoo.com/app/drills" "https://www.duolingo.com" "http://stackoverflow.com"

launchctl list shows error code 8 for com.blockjunk.server.plist - does anyone know status code 8 means or what I might be doing wrong?

Here's the permissions on startserver.sh -rwxr-xr-x 1 jeff staff 248B Feb 6 10:16 startserver.sh

The plist is in ~/Library/LaunchAgents/

È stato utile?

Soluzione 2

I needed to put the plist in /Library/LaunchDeamons to run it as root because the node process needed root access.

Altri suggerimenti

Error code 8: Exec format error. A request was made to execute a file that, although it has the appropriate permissions, was not in the format required for an executable file.

Start the job manually from Terminal.app. What exactly is the error message?

1) Job failed to exec(3) for weird reason: 8: launchd was unable to execute the job specified in ProgramArguments. Given that you specified a proper bang line this is unlikely.

2) Exited with code: 8: The script launchd called returned this error. Try running the script manually. Does it work?

It is important to know what exactly the error message is. Otherwise it is impossible to tell what error code 8 is because we do not know which process reported it. launchd reports standard error codes but software in general is not required to do that.

To find out what a standard error code means enter the following command:

perl -E 'say $!=shift' 8

Just replace the 8 by the code you are looking for.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top