- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用pm2 (版本3.4.1)管理Laravel Echo websocket server 。它运行完美,但我试图让它在机器重新启动(运行 Ubuntu 16.04)后自动启动。为此,我遵循 these instructions :
$ pm2 startup
[PM2] Init System found: systemd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/usr/bin /usr/local/share/.config/yarn/global/node_modules/pm2/bin/pm2 startup systemd -u kramer65 --hp /home/kramer65
$ sudo env PATH=$PATH:/usr/bin /usr/local/share/.config/yarn/global/node_modules/pm2/bin/pm2 startup systemd -u kramer65 --hp /home/kramer65
[sudo] password for kramer65:
[PM2] Init System found: systemd
Platform systemd
Template
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target
[Service]
Type=forking
User=kramer65
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/home/kramer65/.pm2
PIDFile=/home/kramer65/.pm2/pm2.pid
ExecStart=/usr/local/share/.config/yarn/global/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/local/share/.config/yarn/global/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/local/share/.config/yarn/global/node_modules/pm2/bin/pm2 kill
[Install]
WantedBy=multi-user.target
Target path
/etc/systemd/system/pm2-kramer65.service
Command list
[ 'systemctl enable pm2-kramer65' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-kramer65.service
[PM2] Making script booting at startup...
[PM2] [-] Executing: systemctl enable pm2-kramer65...
[PM2] [v] Command successfully executed.
+---------------------------------------+
[PM2] Freeze a process list on reboot via: $ pm2 save
[PM2] Remove init script via: $ pm2 unstartup systemd
然后我运行了pm2 save
:
$ pm2 save
[PM2] Saving current process list...
[PM2] Successfully saved in /home/kramer65/.pm2/dump.pm2
此后,我重新启动计算机,重新登录 ssh,并检查 pm2 进程:
$ pm2 status
┌──────────┬────┬─────────┬──────┬─────┬─────────┬─────────┬────────┬─────┬────────┬────────┬──────────┐
│ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
├──────────┼────┼─────────┼──────┼─────┼─────────┼─────────┼────────┼─────┼────────┼────────┼──────────┤
│ echo │ 0 │ N/A │ fork │ N/A │ errored │ 0 │ 0 │ 0% │ 0 B │ kramer65 │ disabled │
└──────────┴────┴─────────┴──────┴─────┴─────────┴─────────┴────────┴─────┴────────┴────────┴──────────┘
Use `pm2 show <id|name>` to get more details about an app
如您所见,状态错误。如果我停止并启动该进程(pm2 stop echo && pm2 start echo
),该进程将再次运行。
错误日志(~/.pm2/pm2.log)告诉我:
2019-05-14T11:56:36: PM2 log: ===============================================================================
2019-05-14T11:56:36: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
2019-05-14T11:56:36: PM2 log: Time : Tue May 14 2019 11:56:36 GMT+0200 (CEST)
2019-05-14T11:56:36: PM2 log: PM2 version : 3.4.1
2019-05-14T11:56:36: PM2 log: Node.js version : 8.15.1
2019-05-14T11:56:36: PM2 log: Current arch : x64
2019-05-14T11:56:36: PM2 log: PM2 home : /home/kramer65/.pm2
2019-05-14T11:56:36: PM2 log: PM2 PID file : /home/kramer65/.pm2/pm2.pid
2019-05-14T11:56:36: PM2 log: RPC socket file : /home/kramer65/.pm2/rpc.sock
2019-05-14T11:56:36: PM2 log: BUS socket file : /home/kramer65/.pm2/pub.sock
2019-05-14T11:56:36: PM2 log: Application log path : /home/kramer65/.pm2/logs
2019-05-14T11:56:36: PM2 log: Process dump file : /home/kramer65/.pm2/dump.pm2
2019-05-14T11:56:36: PM2 log: Concurrent actions : 2
2019-05-14T11:56:36: PM2 log: SIGTERM timeout : 1600
2019-05-14T11:56:36: PM2 log: ===============================================================================
2019-05-14T11:56:36: PM2 log: App [echo:0] starting in -fork mode-
2019-05-14T11:56:36: PM2 log: App [echo:0] online
2019-05-14T11:56:36: PM2 error: Error: spawn node ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:362:16)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)
有人知道这里出了什么问题吗?
最佳答案
ENOENT
代表No such directory entry
env <command>
正在做? (by Chris Johnsen) env
command用于在自定义环境中运行另一个程序而不修改当前程序。
sudo env PATH=$PATH:/usr/bin \
/usr/local/share/.config/yarn/global/node_modules/pm2/bin/pm2 \
startup systemd -u kramer65 --hp /home/kramer65
Installation note from pm2 documentation To detect available init systems on your machine and generate a configuration, use:
pm2 startup
$ [PM2] You have to run this command as root. Execute the following command:
$ sudo su -c env PATH=$PATH:/home/unitech/.nvm/versions/node/v4.3/bin pm2 startup <distribution> -u <user> --hp <home-path>
我将把命令分解如下
sudo env name=value name2=value2 program and args
1) 计划
运行命令程序 /usr/local/share/.config/yarn/global/node_modules/pm2/bin/pm2
The first remaining argument specifies the program name to invoke; it is searched for according to the `PATH' environment variable.
2)论据通过
Any remaining arguments are passed as arguments to that program.
args
传递至pm2
cli 命令是 startup systemd -u kramer65 --hp /home/kramer65
.
startups
命令将简单地设置 pm2
在启动时启动 ( Startup Cli Commands )systemd
命令用于支持的 init 系统 Ubuntu => 16, CenOS >=7, Arch, Debian >=7
( Startup Hooks Compatability ) 并应更改为正确的 platform
正如所包含的文档所示。3) 用于执行程序的环境
with an environment formed by extending the current environment with the environment variables and values designated by name=value and name2=value2.
如 pm2
docs 应该是 /home/kramer/.nvm/versions/node/v4.3/bin
内的文件夹
PATH=$PATH:/home/unitech/.nvm/versions/node/v4.3/bin
当您使用 home
之外的文件夹时目录,因为您在 nodejs
上运行旧版本(参见上一章 Nodejs 安装在 usr/bin/node 中)。
PATH=$PATH:/usr/bin
4) 用户权限
您正在通过--user kramer65 --home-path /home/kramer65
到pm2
cli 命令。
-u <user> --hp <home-path>
The startup hook auto load the process list that you have previously saved. Save your process list with:
pm2 save
Nodejs
安装在usr/bin/node
(Error: spawn ENOENT on Ubuntu 14.04)How to reproduce: you have two version of nodejs on your computer. One is an old version installed in
/usr/bin/node
and the other one is a recent version located in./nodejs/node
. I launch my pm2 manager programmatically, by calling./nodejs/node myManager.js
, which will call pm2.connect(), which will try to spawn the PM2 Daemon.What happen is that the PM2 Daemon will be launched using the old node binary from
/usr/bin/node
instead of the recent node binary running my myManager.js script (locatedin./nodejs/node
).What this does is look for a node binary in the current directory, and then default to node binaries in the path. BUT the node binary running the current code is in
./nodejs/node
. To launch the PM2 daemon with the same node binary as the current process, you need to use process.execPath
关于javascript - 机器重启后 pm2 托管进程处于错误状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56131140/
我有一个 UWP 应用程序(在 Windows/Microsoft Store 中发布),我正在进行新的更新,我在我的应用程序中使用了 Template10,它具有深色和浅色主题,并且在 Window
我是 spring batch 的新手,有一些关于暂停/恢复的问题。看了spring batch的文档,好像没有内置的pause或者resume功能。但是,我从主站点找到了这个用例: http://d
我正在编写一个网络服务并有以下观察结果:即使我只是将一个文本文件添加到存储 web 服务引用的所有 dll 的目录 (bin),appdomain 也会刷新。 这会导致存储在字典(在其中一个 dll
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 6 年前。 Improve this qu
Hadoop 1.0.3 工作 36 小时后说: INFO mapred.JobClient: map 42% reduce 0% mapred.JobClient: Job Failed
我使用 AVAssetWriter 将视频录制到文件中。所以我为此创建了类。 link to gist 然后在项目的某处我推送记录并开始录制视频。 func start() { assetWriter
我想要一个在后台运行的 python 脚本(无限循环)。 def main(): # inizialize and start threads [...] try:
我在重新启动 Activity 时感到困惑。我有两个功能可以很好地完成同一任务。请指导我哪个最好,为什么? public void restart() { Intent
重启sidekiq的正确方法是什么。它似乎在我启动它时缓存了我的 worker 代码,所以每次我对我的 worker 进行更改时我都需要重新启动它。我正在使用 Ctrl/C 执行此操作,但该过程需要很
我在我的 Android 模拟器上安装了新字体。说明说我必须重新启动设备。我尝试使用“关机”按钮,但它只显示“正在关机”并且什么也不做。即使我去 adb shell 并运行“重启”它也会挂起。 任何想
启动操作 ? 1
关闭 service nginx stop systemctl stop nginx 启动 service nginx start systemctl start n
正在学习Linux中。。。一边学一边记录着。。所有观点只是个人观点 Linux有个文件 /etc/inittab 复制代码 代码如下:
如果我运行 systemctl restart kubelet它会影响其他正在运行的节点吗?它会停止集群吗?你能预见任何影响吗? 任何帮助,将不胜感激! 最佳答案 在回答之前,小声明:重启不是由于对
嗯,问题是我有一个在 MATE 上完美运行的 Abyssus Razer,但是 在 Debian、Elementary、OpenSUSE 和其他平台上,默认 设置 super 慢。 我用 解决了这个问
我在 Ubuntu 16.04 上安装了 NGINX 并编辑了我的配置。 当我想用 sudo service nginx restart 重新启动时我得到错误: Job for nginx.servi
我已经在我的 Ubuntu 上安装了 Gearman Job Server(又名 Gearmand)1.0.6: Distributor ID: Ubuntu Description: Ubun
我有一个 WiX Burn使用 ManagedBootstrapperApplicationHost 的自定义安装程序。安装必备 Microsoft Windows Installer 之一后4.5
我已经使用 brew install mosquitto 在我的 mac 上安装了蚊子代理. 通常我不会给出任何命令来启动 mosquitto 服务器。当我打开我的 mac 时它会自动启动。 我已经使
我有一个带有 2 个容器的 pod test-1495806908-xn5jn。我想重新启动其中一个名为 container-test 的项目。是否可以重新启动 Pod 中的单个容器以及如何重新启动?
我是一名优秀的程序员,十分优秀!