D
D
den4eg112015-11-16 04:00:03
Node.js
den4eg11, 2015-11-16 04:00:03

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

3 answer(s)
D
den4eg11, 2015-11-18
@den4eg11

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

K
Konstantin Kitmanov, 2015-11-16
@k12th

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.

N
Nikon_NLG, 2015-11-16
@Nikon_NLG

Have you tried chdir first?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question