2

I have an upstart script like so:

start on runlevel [2345]
respawn

script
  exec su - ubuntu -c "cd /opt/app; bin/widget 2>&1 | logger -t 'widget'"
end script

The problem is when the widget process crashes, it doesn't respawn. Presumably because the logger process is still running. Any way around this?

1 Answer 1

1

I would "outsource" the work to a bash script:

start on runlevel [2345]
respawn

script
  exec /path/to/bash/script
end script

the script

#! /bin/bash -e

su - ubuntu -c "cd /opt/app; bin/widget" |& logger -t 'widget'

exit ${PIPESTATUS[0]}

The PIPESTATUS array in bash stores pipe return values, in this case we use the return value of the su command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .