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
594 stars 65 forks source link

Doesn't work on CentOS 6.7 (Final) #62

Closed jpSimkins closed 8 years ago

jpSimkins commented 8 years ago

I have manually setup a project and when I invoke it, it runs as expected.

I then, installed forever and forever-service globally.

I setup my project by cd into the directory (where the main.js file is located) and ran

# sudo forever-service install portal --script main.js
forever-service version 0.5.7

Platform - CentOS release 6.7 (Final)

portal provisioned successfully

Commands to interact with service portal
Start   - "sudo service portal start"
Stop    - "sudo service portal stop"
Status  - "sudo service portal status"
Restart - "sudo service portal restart"

So far everything is great. I killed my project manually to test this service.

I ran: service portal start and got: Starting portal as expected but the app is not running.

I check the log and I see a lot of the same errors:

Error: `/APP_PATH/public_html/build/bundle/programs/server/node_modules/fibers/bin/linux-x64-v8-4.5/fibers.node` is missing. Try reinstalling `node-fibers`?
    at Object.<anonymous> (/APP_PATH/public_html/build/bundle/programs/server/node_modules/fibers/fibers.js:16:8)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/APP_PATH/public_html/build/bundle/programs/server/boot.js:1:75)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
error: Forever detected script exited with code: 1
error: Script restart attempt #44
/APP_PATH/public_html/build/bundle/programs/server/node_modules/fibers/fibers.js:16
    throw new Error('`'+ modPath+ '.node` is missing. Try reinstalling `node-fibers`?');

APP_PATH is the correct path, just removed for posting this.

Why am I getting this error when using forever-service but not when I manually invoke my app?

So I assumed it was missing the PATH and added that to the /etc/init.d/portal file.

I added

# result of whereis forever or whereis node
export PATH=$PATH:/usr/bin  
# result of whereis node_modules
export NODE_PATH=$NODE_PATH:/usr/lib/node_modules:/usr/local/lib/node_modules

Same issue as above. Same error.

I also noted that when I stopped the service, it stated it stopped but when I started it, it was already running.. That may be due to it not running properly so I am ignoring that at this time.

So I deleted the forever-service I just created: sudo forever-service delete portal

I then manually started my app to make sure it wasn't an issue with my code and no issues.

So I wanted to make sure I was doing this correctly... I tried again.

This time, I ran sudo forever-service install portal --script main.js and got the output below.

# sudo forever-service install portal --script main.js
forever-service version 0.5.7

Platform - CentOS release 6.7 (Final)

portal provisioned successfully

Commands to interact with service portal
Start   - "sudo service portal start"
Stop    - "sudo service portal stop"
Status  - "sudo service portal status"
Restart - "sudo service portal restart"

I then edited the /etc/init.d/portal file and added

# result of whereis forever or whereis node
export PATH=$PATH:/usr/bin  
# result of whereis node_modules
export NODE_PATH=$NODE_PATH:/usr/lib/node_modules:/usr/local/lib/node_modules

below

#Setup Environment variables (if any)

And the exact same issue... I am getting numerous log entries of:

Error: `/APP_PATH/public_html/build/bundle/programs/server/node_modules/fibers/bin/linux-x64-v8-4.5/fibers.node` is missing. Try reinstalling `node-fibers`?
    at Object.<anonymous> (/APP_PATH/public_html/build/bundle/programs/server/node_modules/fibers/fibers.js:16:8)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/APP_PATH/public_html/build/bundle/programs/server/boot.js:1:75)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
error: Forever detected script exited with code: 1
error: Script restart attempt #44
/APP_PATH/public_html/build/bundle/programs/server/node_modules/fibers/fibers.js:16
    throw new Error('`'+ modPath+ '.node` is missing. Try reinstalling `node-fibers`?');

So at this point, I must assume it's something wrong with forever-service.

I hope this helps isolate any issue that may be happening. Or perhaps I missed a step...

The server is running:

# node -v
v0.10.43
#npm -v
1.4.29

These are requirements since we are using meteor.

Thanks

jpSimkins commented 8 years ago

More investigation shows that forever is not mapping to the correct file location.

# sudo forever list
info:    Forever processes running
data:        uid    command       script  forever pid   id logfile             uptime  
data:    [0] portal /usr/bin/node main.js 10345   10452    /var/log/portal.log STOPPED 

When I run:

# /usr/bin/node main.js 
Error: `/APP_PATH/public_html/build/bundle/programs/server/node_modules/fibers/bin/linux-x64-v8-4.5/fibers.node` is missing. Try reinstalling `node-fibers`?
    at Object.<anonymous> (/APP_PATH/public_html/build/bundle/programs/server/node_modules/fibers/fibers.js:16:8)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/APP_PATH/public_html/build/bundle/programs/server/boot.js:1:75)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
error: Forever detected script exited with code: 1
error: Script restart attempt #44
/APP_PATH/public_html/build/bundle/programs/server/node_modules/fibers/fibers.js:16
    throw new Error('`'+ modPath+ '.node` is missing. Try reinstalling `node-fibers`?');

I am seeing the exact error I have in my log. I also noticed that the node being loaded is not the correct one. So this issue is not really a problem with forever-service but more an issue with using nvm