首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >centos+nodejs+forever(startstop)

centos+nodejs+forever(startstop)
EN

Stack Overflow用户
提问于 2012-06-26 13:37:17
回答 1查看 2.4K关注 0票数 2

好的,我有一些永远开始\停止脚本的问题。

CentOS 6.2

内核2.6.32-220.el6.x86_64

nodejs v0.6.19

npm诉1.1.24

永远@0.9.2

我创建nologin用户来运行我的脚本

/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

我创建脚本并命名为hello2.js

代码语言:javascript
复制
  #!/bin/bash
echo "aight" 

试着跑

代码语言:javascript
复制
  [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

一切都很好。接下来,我为hello2.js创建了启动停止脚本,并将其命名为节。

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

代码语言:javascript
复制
#!/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

=========================================使其可执行。

下一个我想看看这个是如何运作的

代码语言:javascript
复制
[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**

代码语言:javascript
复制
[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]$

我的错误在哪里?

EN

回答 1

Stack Overflow用户

发布于 2013-04-26 18:10:38

试一试

代码语言:javascript
复制
nohup forever start -l forever.log -o out.log -e err.log /home/max/Desktop/hello2.js &
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11208549

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档