1

My Node.js server upstart job config:

start on (net-device-up and runlevel [2345] and started td-agent)
stop on runlevel [016]

respawn

env HOME="/var/nodes"

script
    chdir $HOME
    exec /usr/local/bin/node index.js -c app/config/live >> /var/log/node/server.log 2>> /var/log/node/server_error.log
end script

When I run:

initctl check-config node

I got this:

node
  start on: unknown job td-agent

When Server is booted, Node is down, but I can manually start it:

service node start
node start/running, process 1156

EDIT: If I remove and started td-agent, it is started on boot. But I need Node started after td-agent. How can I fix this issue?

Roman Newaza
  • 632
  • 4
  • 13
  • 23

1 Answers1

2

Upstart seems to know nothing about td-agent. That is because upstart only recognizes jobs started by upstart.

Probably td-agent is started by a script in /etc/init.d. If that is the case, you can not use upstart to start node and have it depend on td-agent.

The solution is not to use upstart. You need to write a new script to /etc/init.d that starts node.

You must make it run after td-agent start script. When you have your script, use update-rc.d command to define when it starts.

Here is a link to an example minimal start script. It is for liferay but just fix the environment variables, and replace start() and stop() functions with your own definitions. Example liferay initd script.

vesako
  • 326
  • 1
  • 5
  • Yes, `td-agent` is started by `/etc/init.d` script. I thought `upstart daemon` monitors processes for `td-agent`, but you say it has to be `upstart job` - sounds reasonable. Yea, I know how to create start / stop scripts. Thank you! – Roman Newaza Mar 18 '13 at 01:21