Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"No forever processes running" when run it in rc.local on Ubuntu #713

Open
unbug opened this issue Jun 14, 2015 · 3 comments
Open

"No forever processes running" when run it in rc.local on Ubuntu #713

unbug opened this issue Jun 14, 2015 · 3 comments

Comments

@unbug
Copy link

unbug commented Jun 14, 2015

In order to start the server on system start,I create a server.sh file

#!/bin/sh
forever start /srv/www/ddms/ddms/bin/www & forever start /srv/www/ddms/ddms/bin/api

then I link the file in my rc.local

/srv/www/ddms/server.sh > /tmp/server.sh.out 2>&1

Now I want to restart my app with

forever restartall

It wont work,so,I checked

forever list

It shows me "No forever processes running"
In my case,how cant I restart my app?

@christopherhex
Copy link

I'm experiencing the same issue. I have a startup script which calls forever and starts a node.js app. When manually executing the script, forever list returns the application, however when rc.local executes the script, it can't be seen in forever listonce logged in. Then it returns: No forever processes running

I guess this is something related to the OS, as pm2 (another node process manager) shows the same issues.

@mattdodge
Copy link

I had the same issue but I don't think it's actually a bug. Forever, as it stands, is intentionally on a per-user basis. Look at issue #544 for more details.

What you're seeing is a difference between running as the root user and running as sudo. They are similar, but not the same. When rc.local is run during startup, it is done as the root user and the forever config directory is going to be relative to the root user's home directory. This is likely /root/.forever. However, when you run forever using sudo, it will still use your home directory and will be looking for forever processes in ~/.forever.

So, what you can do, is in your rc.local change where the forever root will be to the root of the user you want to run as.

export FOREVER_ROOT=/home/myusername/.forever
forever start myscript.js

It sounds like there are talks of moving the forever root to a system-wide folder like /opt, but for now, you may have to hack around with the root folder to see your processes.

@graywithanA
Copy link

I know this an old issue but I was having problems with this and the solution by @mattdodge didn't work for me so I wanted to add my $0.02.

Be careful with your file path in the rc.local file. If you include ~ in your path you'll likely run into problems since this is run as root. In my case I wasn't calling forever directly in the rc.local file but was calling a script which then invoked forever. The path used in the script to call forever and designate log locations used ~ and I didn't want to change the paths in the script.

To get around the issue this was causing I used runuser in the rc.local file to run the script as the correct user. My addition to the rc.local file was:
runuser -l myusername -c 'cd /home/myuser/project/root && npm run foreverScript'

No need to set FOREVER_ROOT anymore since the command gets run as the correct user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants