zapty / forever-service

Provision node script as a service via forever, allowing it to automatically start on boot, working across various Linux distros and OS
https://github.com/zapty/forever-service
MIT License
595 stars 65 forks source link

forever: command not found on start #2

Closed aronduby closed 10 years ago

aronduby commented 10 years ago

Attempting to use this tool but it keeps saying that the forever command is not found on line 51 and 63 whenever I attempt to start the service. Both forever and forever-service were installed globally as root. Here's the full output:

[root@server /etc/init.d]$ forever-service install -s /web/grpl/node/server.js grpl
forever-service version 0.2.3

Platform - CentOS release 6.5 (Final)

grpl provisioned successfully

Commands to interact with service grpl
Start   - "sudo service grpl start"
Stop    - "sudo service grpl stop"
Status  - "sudo service grpl status"
Restart - "sudo service grpl restart"
[root@server /etc/init.d]$ service grpl start
/etc/init.d/grpl: line 51: forever: command not found
Starting grpl
/etc/init.d/grpl: line 63: forever: command not found

After my first attempt not working I removed both forever and forever-script and re-installed them (again as root) since my install of forever was getting a bit old, but that made no noticeable difference.

arvind-agarwal commented 10 years ago

Can you just try running forever as sudo i.e. sudo forever and see if it works? I want to confirm forever is available in path when run as sudo.

aronduby commented 10 years ago

It does NOT work

arvind-agarwal commented 10 years ago

Please give me output of the following to further debug this,

sudo -s whereis forever echo $PATH

aronduby commented 10 years ago

forever is in /usr/local/bin/forever (which is actually a symlink) $PATH is /sbin:/bin:/usr/sbin:/usr/bin

I did some poking around and came upon http://superuser.com/questions/548508/why-cant-i-sudo-some-commands-e-g-vim and removed the secure path variable as suggested (as root using visudo) and that didn't fix the issue

arvind-agarwal commented 10 years ago

Great. I will also create a patch to provide a path for forever, this way for such situations you can manually feed in that path while provisioning the service

arvind-agarwal commented 10 years ago

I have added cli arguments -p --foreverPath to specify the path, so you could now use following command as well,

forever-service install -s /web/grpl/node/server.js -p /usr/local/bin grpl

aronduby commented 10 years ago

that fixed the forever error, but now I have the same issue with it not finding node

arvind-agarwal commented 10 years ago

You can try using -c option with forever to specify node path On 19 Oct 2014 22:33, "aronduby" notifications@github.com wrote:

that fixed the forever error, but now I have the same issue with it not finding node

— Reply to this email directly or view it on GitHub https://github.com/zapty/forever-service/issues/2#issuecomment-59656388.

aronduby commented 10 years ago

I ran whereis node which gave me /usr/local/bin/node so I changed the install command to be

forever-service install -s /web/grpl/node/server.js -p /usr/local/bin -f " -c /usr/local/bin/node" grpl

and now when trying to start it gives the error /usr/bin/env: node: No such file or directory

arvind-agarwal commented 10 years ago

http://stackoverflow.com/questions/20886217/browserify-error-usr-bin-env-node-no-such-file-or-directory

Looks like solution for /usr/bin/env: Node error ..

buno047 commented 8 years ago

Thank you Arvind. For CentOS, I had needed to find "whereis node" Then simply create a symlink of that file to /usr/bin/node and then forever-service works fine.