question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.foreverignore file not working for sub directories with -w

See original GitHub issue

Normal ignore rules don’t seem to work correctly with forever. I was trying to add my .git folder and was unable to get it working. I tried with the below file.

.git
.git/
.git/*

The first line is the only one that should be needed.

If you did a git pull and a file changed in the .git folder forever would restart.

info:   restaring script because /mnt/home/test/.git/FETCH_HEAD changed
warn: Forever detected script exited with code: null
warn: Forever restarting script for 1 time

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:47 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jeffmcmahancommented, Nov 17, 2018

I love forever, and have used the CLI for many years in many projects. The developers deserve enormous credit.

Now, I’m using v0.15.3 and in my case, ignored subdirectories are being watched. This has been so for years, and I’ve come back to this thread a half dozen times over the past 4-5 years.

I think the following sums up the situation: (i) The maintainers seemed to regard the problem with the CLI as fixed before it worked the way the users above wanted. (ii) There’s no test in place that covers the way the users above want the CLI to work.

The following demonstrates the the CLI does not respect .foreverignore subdirectories, exactly as OP described (paste into terminal):

# Create a project directory.
cd ~ && mkdir foo-project

# Create project files.
echo "require('http').createServer(r => {}).listen(3000)" > foo-project/index.js
mkdir foo-project/foo
mkdir foo-project/foo/bar
echo "console.log('fizz');" > foo-project/foo/bar/index.js

# Add .foreverignore to tell forever to ignore foo.
echo "foo" > foo-project/.foreverignore

# Add a JSON conf file to tell forever to watch the project.
echo "{\"watch\":true,\"script\":\"index.js\"}" > foo-project/forever-conf.json

# Run the project.
cd foo-project && forever start forever-conf.json

$ forever list will show a running process. Now we’ll change a file that lives in foo/bar (paste into terminal):

cd ../
echo "console.log('buzz');" >> foo-project/foo/bar/index.js

The process should not have restarted, but the log file will indicate that it did so:

error: restarting script because add changed
error: Forever detected script was killed by signal: SIGKILL
error: Script restart attempt #1

If I’m doing something wrong here, please indicate how I should change what I’m doing; I’ll be grateful.

1reaction
freewilcommented, Jun 26, 2014

**/.git/** is working for me in .foreverignore with v0.11.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - .foreverignore file not working for sub directories with -w -
Normal ignore rules don't seem to work correctly with forever. I was trying to add my .git folder and was unable to get...
Read more >
Ignore config file with nodeJS/forever - Stack Overflow
I have searched a lot, and have not been able to find a simple example of how to exclude a specific file (or...
Read more >
Setup Node.js on EC2 with forever - Anil
A guide on setting up node.js on an EC2 server with forever to run a HTTP server.We also setup forever to run our...
Read more >
Forever.js in WebStorm 2016.2 – IDEs Support (IntelliJ Platform)
Basically, I have node.js debug profile set up to run my node script with the -w flag (watch files for changes). Today, after...
Read more >
Working with folders in Node.js
readdir() to read the contents of a directory. This piece of code reads the content of a folder, both files and subfolders, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found