启动node.js服务器时Ansible挂起 [英] Ansible hangs when starting node.js server

查看:144
本文介绍了启动node.js服务器时Ansible挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个简单的剧本中启动我的node.js应用程序.现在,最终指令看起来像这样:

I would like to start my node.js app in an ansible playbook. Right now, the final directive looks like this:

  - name: start node server
    shell: chdir=${app_path} npm start&

问题在于,ansible永远不会从中返回.如何使它继续?

The problem is that ansible never returns from this. How can I make it continue?

推荐答案

永远似乎是最简单的最简单的启动和守护Node.js应用程序的方法.当前,永远没有Ansible模块,但是您仍然可以使用以下播放器永久安装并运行您的应用程序:

Forever seems to be the simplest and easiest way of starting and daemonizing Node.js apps. Currently, there's no Ansible module for forever, but you can still use the following plays to install forever and run your app:

- name: "Install forever (to run Node.js app)."
  npm: name=forever global=yes state=present

- name: "Check list of Node.js apps running."
  command: forever list
  register: forever_list
  changed_when: false

- name: "Start example Node.js app."
  command: forever start /path/to/app.js
  when: "forever_list.stdout.find('/path/to/app.js') == -1"

这完全是幂等的,对我来说非常有用.您可以为Ansible编写一些forever模块,以为您完成此操作(例如service模块),但是现在可以使用.

This is completely idempotent, and works great for me. You could program a little forever module for Ansible to do this stuff for you (like the service module), but this works for now.

我有一个完整的示例,说明如何启动节点.服务器Check.in博客上的永远与Ansible的js应用.

I have a complete example of how to start a Node.js app with Forever and Ansible on Server Check.in's blog.

这篇关于启动node.js服务器时Ansible挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆