I want to run my simple Node server as a background process within my Docker container but when I try and fire it up using forever I get the following:

fs.js:432
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
Error: ENOENT, no such file or directory '/.forever/9Spa.log'

So I tried just making a folder called .forever in my current working directory but then I got pretty much the same error (the *.log file has a different name each time I run it, as expected.)

If I run my server without using forever it runs fine without any errors. E.g:

node server

or

npm start

both work fine, but of course don't run in the background.

I get the same error just running

forever list

So the issue it clearly with forever and not my server code.

npm list -g shows that forever is installed.

I am using a Ubuntu 14.04.1 LTS image in my Docker container.

I'm open to suggestions.

update

I finally got forever to run my making a .forever folder in /home/testuser and within that a pids folder, then running the following:

forever start -p /home/testuser/.forever --pidFile /home/testuser/.forever/pids/server.pid server.js

According to the docs

-p PATH Base path for all forever related files (pid files, etc.)

However that's not quite true. I was forced to specify the absolute path for the --pidFile

So, hooray, my server is running as a background process. However the following still break:

forever stop server.js

=> /usr/local/lib/node_modules/forever/lib/forever.js:634 var procs = processes.filter(function (p) { ^ TypeError: Object Error: EACCES, mkdir '/.forever' has no method 'filter' at Object.forever.findByScript (/usr/local/lib/node_modules/forever/lib/forever.js:634:25) at /usr/local/lib/node_modules/forever/lib/forever.js:189:20 at /usr/local/lib/node_modules/forever/lib/forever.js:136:14 at /usr/local/lib/node_modules/forever/lib/forever.js:89:20 at /usr/local/lib/node_modules/forever/node_modules/utile/node_modules/mkdirp/index.js:34:29 at /usr/local/lib/node_modules/forever/node_modules/utile/node_modules/mkdirp/index.js:46:53 at Object.oncomplete (fs.js:107:15)

forever stop -p /home/bit2bit/.forever server.js

same result

forever list

==> /usr/local/lib/node_modules/forever/lib/forever.js:683 procs.forEach(function (proc) { ^ TypeError: Object Error: EACCES, mkdir '/.forever' has no method 'forEach' at Object.forever.format (/usr/local/lib/node_modules/forever/lib/forever.js:683:11) at /usr/local/lib/node_modules/forever/lib/forever.js:520:28 at /usr/local/lib/node_modules/forever/lib/forever.js:136:14 at /usr/local/lib/node_modules/forever/lib/forever.js:89:20 at /usr/local/lib/node_modules/forever/node_modules/utile/node_modules/mkdirp/index.js:34:29 at /usr/local/lib/node_modules/forever/node_modules/utile/node_modules/mkdirp/index.js:46:53 at Object.oncomplete (fs.js:107:15)

So, while I can now start my server, I can't stop it again.

share|improve this question
    
so it turns out simply ensuring there is a /.forever folder and /.forever/pids folder (by making them when the Dockerfile is building) means I can happily just run forever start server.js and forever list etc. – Dave Sag Aug 13 '14 at 23:58

Where does forever store console.log output?

try adding a -o argument to specify where the log will be output to.

share|improve this answer
    
Thanks Sam, that worked - I needed to create my own logs folder and specify the absolute path to the logs as follows forever -l /home/testuser/logs/server.log -o /home/testuser/logs/out.log -e /home/testuser/logs/err.log for it to work. – Dave Sag Aug 13 '14 at 3:11
    
Alas on further investigation all that did was force forever to log the same error message into the specified log file. I've since discovered a whole lot more and will update my question with the details. – Dave Sag Aug 13 '14 at 23:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.