2

Good day i have some problem with forever start\stop script.

CentOS 6.2
kernel 2.6.32-220.el6.x86_64
nodejs v0.6.19
npm v 1.1.24
forever@0.9.2

i create nologin user for running my script

/etc/passwd
node:x:501:501::/usr/sbin/nologin:/bin/bash:/usr/local/bin/node:/usr/local/bin/forever:/usr/local/bin:/usr/local/lib/node_modules/forever/bin

i create script and named hello2.js

  #!/bin/bash
echo "aight" 

and try to running

  [max@localhost Desktop]$ forever start hello2.js
    info: Forever processing file: hello2.js
    [max@localhost Desktop]$ forever list
    info: Forever processes running
    data: uid command script forever pid logfile uptime
    data: [0] n4EB node hello2.js 2675 2728 /home/max/.forever/n4EB.log 0:0:0:0.130

Everything all right. And the next i create start-stop script for hello2.js and named him node

===========================

#!/bin/bash

#proccessname: node

USER=node
PWD=node
node=node
forever=forever

start() {

         forever start -l forever.log -o out.log -e err.log /home/max/Desktop/hello2.js

            }

stop(){

      /usr/local/bin/forever stopall
     }

  restart() {
   stop
   start
    }
    status(){
    /usr/local/bin/forever list
    }

    #see how we were called
    case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    restart)
    stop
    start
    ;;
    status)
    status
    ;;
    *)
    echo $ "usage $0 {start | stop | status | restart}"
    exit 1
    esac
    exit 0

========================================= made it executable.

And the next i want to look how this working

[max@localhost Desktop]$ ./node
$ usage ./node {start | stop | status | restart}

[max@localhost Desktop]$ ./node start
info: Forever processing file: /home/max/Desktop/hello2.js

[max@localhost Desktop]$ ./node status
**info: No forever processes running**

But

[max@localhost Desktop]$ forever start hello2.js
info: Forever processing file: hello2.js
[max@localhost Desktop]$ forever list
info: Forever processes running
data: uid command script forever pid logfile uptime
data: [0] n4EB node hello2.js 2675 2728 /home/max/.forever/n4EB.log 0:0:0:0.130
[max@localhost Desktop]$

where my mistake?

karandash
  • 21
  • 3
  • Did you try `ps ax | grep -Ei "node|forever"` after using your init script to start? – Tamil Jun 26 '12 at 14:13
  • You might take a look at my solution using `upstart` (which is supported on CentOS I believe): http://stackoverflow.com/q/11084279/813718. It might make the entire process a lot easier and enables you to use additional features which are only available when using `forever` from within Node. – Rem.co Jun 26 '12 at 15:32
  • [max@localhost Desktop]$ ps ax | grep -Ei "node|forever" 2675 ? Ss 28:23 node /usr/local/bin/forever start hello2.js 11222 pts/0 S+ 0:00 grep -Ei node|forever 30613 ? S 0:03 gedit /home/max/Desktop/node – karandash Jun 26 '12 at 16:14
  • Is it possible that your start is using a different forever binary? Status and stop use the full path whereas your start does not. – Chris Montanaro Mar 12 '13 at 19:16

1 Answers1

0

Try

nohup forever start -l forever.log -o out.log -e err.log /home/max/Desktop/hello2.js &
rzymek
  • 9,064
  • 2
  • 45
  • 59