Answer the question
In order to leave comments, you need to log in
Why, when using upstart, node defines the application as a module and does not load?
Wrote a script. Works fine. I wanted to make it permanently running with upstart
Main.conf config:
#!upstart
description "main.js "
author "1"
start on runlevel [2345]
stop on shutdown
respawn
script
export HOME="/folder"
echo $$ > /var /run/main.pid
exec /usr/bin/nodejs /folder/folder2/main.js
end script
pre-start script
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting"
end script
pre-stop script
rm /folder/folder2/main.pid
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping"
end script
Logs:
Error: Cannot find module '/folder/folder2/main.js
'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Function.Module. runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
Answer the question
In order to leave comments, you need to log in
I found what the problem is, I think it will be useful not only to me, because I spent a lot of time on this. The whole problem was that unix systems and windows have different line ending formats and because of this I had an invisible character in the code. Solution in notepad: select text - Edit - Format end of lines - convert to unix format
Something is messed up with the path, apparently.
> node defines the application as a module and does not load?
because that's the way it's designed. Ignore the word module if it confuses you, but pay attention to the paths.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question