Monday 13 March 2017

Windows: Auto start PM2 and node apps

At a Windows AWS server i have a NODE app and i'm using PM2 to launch the app

I have tried the NPMs: "pm2-windows-startup" and "pm2-windows-service"

But after i restart my AWS instance and run

PM2 ls

No node app shows up in the list...

I followed the instructions ...

  1. Installed the NPM (So PM2 auto start after reboot)
  2. PM2 start myApp.js --name mySuperApp
  3. PM2 save
  4. Reboot
  5. PM2 ls --> no running node apps? :-(

The PM2 logs dont contain any thing...

I have not added any ENV variables explicit (when i tried PM2 could not start any more - so i created a fresh AWS windows instance and installed every thing from scratch again...)

PM2 is located the default place (i have not changed any paths)

C:\Users\Administrator\.pm2

My PM2 file contains:

2017-03-13 07:37:48: =============================================================================== 2017-03-13 07:37:48: --- New PM2 Daemon started ----------------------------------------------------

2017-03-13 07:37:48: Time : Mon Mar 13 2017 07:37:48 GMT+0000 (Coordinated Universal Time) 2017-03-13 07:37:48: PM2 version : 2.4.2 2017-03-13 07:37:48: Node.js version : 6.10.0 2017-03-13 07:37:48: Current arch : x64 2017-03-13 07:37:48: PM2 home : C:\Users\Administrator.pm2 2017-03-13 07:37:48: PM2 PID file : C:\Users\Administrator.pm2\pm2.pid 2017-03-13 07:37:48: RPC socket file : \.\pipe\rpc.sock 2017-03-13 07:37:48: BUS socket file : \.\pipe\pub.sock 2017-03-13 07:37:48: Application log path : C:\Users\Administrator.pm2\logs 2017-03-13 07:37:48: Process dump file : C:\Users\Administrator.pm2\dump.pm2 2017-03-13 07:37:48: Concurrent actions : 2 2017-03-13 07:37:48: SIGTERM timeout : 1600 2017-03-13 07:37:48: ===============================================================================

2017-03-13 07:37:48: Starting execution sequence in -fork mode- for app name:mySuperApp id:0 2017-03-13 07:37:48: App name:mySuperApp id:0 online 2017-03-13 07:40:45: ===============================================================================

2017-03-13 07:40:45: --- New PM2 Daemon started ---------------------------------------------------- 2017-03-13 07:40:45: Time : Mon Mar 13 2017 07:40:45 GMT+0000 (Coordinated Universal Time) 2017-03-13 07:40:45: PM2 version : 2.4.2 2017-03-13 07:40:45: Node.js version : 6.10.0 2017-03-13 07:40:45: Current arch : x64 2017-03-13 07:40:45: PM2 home : C:\Users\Administrator.pm2 2017-03-13 07:40:45: PM2 PID file : C:\Users\Administrator.pm2\pm2.pid 2017-03-13 07:40:45: RPC socket file : \.\pipe\rpc.sock 2017-03-13 07:40:45: BUS socket file : \.\pipe\pub.sock 2017-03-13 07:40:45: Application log path : C:\Users\Administrator.pm2\logs 2017-03-13 07:40:45: Process dump file : C:\Users\Administrator.pm2\dump.pm2 2017-03-13 07:40:45: Concurrent actions : 2 2017-03-13 07:40:45: SIGTERM timeout : 1600 2017-03-13 07:40:45: ===============================================================================

My PM2 DUMB file contains:

[ { "exec_mode": "fork_mode", "watch": false, "treekill": true, "autorestart": true, "automation": true, "pmx": true, "vizion": true, "name": "mySuperApp", "node_args": [], "pm_exec_path": "c:\mypath\mySuperApp\server.js", "env": { "windir": "C:\Windows", "USERPROFILE": "C:\Users\Administrator", "USERNAME": "Administrator", "USERDOMAIN_ROAMINGPROFILE": "EC2AMAZ-REBQJDK", "USERDOMAIN": "EC2AMAZ-REBQJDK", "TMP": "C:\Users\ADMINI~1\AppData\Local\Temp\2", "TEMP": "C:\Users\ADMINI~1\AppData\Local\Temp\2", "SystemRoot": "C:\Windows", "SystemDrive": "C:", "SESSIONNAME": "RDP-Tcp#1", "PUBLIC": "C:\Users\Public", "PSModulePath": "C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\AWS Tools\PowerShell\", "PROMPT": "$P$G", "ProgramW6432": "C:\Program Files", "ProgramFiles(x86)": "C:\Program Files (x86)", "ProgramFiles": "C:\Program Files", "ProgramData": "C:\ProgramData", "PROCESSOR_REVISION": "3f02", "PROCESSOR_LEVEL": "6", "PROCESSOR_IDENTIFIER": "Intel64 Family 6 Model 63 Stepping 2, GenuineIntel", "PROCESSOR_ARCHITECTURE": "AMD64", "PM2_USAGE": "CLI", "PM2_INTERACTOR_PROCESSING": "true", "PATHEXT": ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JSE;.WSF;.WSH;.MSC", "Path": "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Amazon\cfn-bootstrap\;C:\Program Files\nodejs\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Roaming\npm", "OS": "Windows_NT", "NUMBER_OF_PROCESSORS": "1", "LOGONSERVER": "\\EC2AMAZ-REBQJDK", "LOCALAPPDATA": "C:\Users\Administrator\AppData\Local", "HOMEPATH": "\Users\Administrator", "HOMEDRIVE": "C:", "ComSpec": "C:\Windows\system32\cmd.exe", "COMPUTERNAME": "EC2AMAZ-REBQJDK", "CommonProgramW6432": "C:\Program Files\Common Files", "CommonProgramFiles(x86)": "C:\Program Files (x86)\Common Files", "CommonProgramFiles": "C:\Program Files\Common Files", "CLIENTNAME": "THESILVERFOX", "APPDATA": "C:\Users\Administrator\AppData\Roaming", "ALLUSERSPROFILE": "C:\ProgramData", "PM2_HOME": "C:\Users\Administrator\.pm2", "mySuperApp": {} }, "pm_cwd": "c:\mypath\mySuperApp", "exec_interpreter": "node", "pm_out_log_path": "C:\Users\Administrator\.pm2\logs\mySuperApp-out-0.log", "pm_err_log_path": "C:\Users\Administrator\.pm2\logs\mySuperApp-error-0.log", "pm_pid_path": "C:\Users\Administrator\.pm2\pids\mySuperApp-0.pid", "km_link": false, "NODE_APP_INSTANCE": 0, "vizion_running": false, "windir": "C:\Windows", "USERPROFILE": "C:\Users\Administrator", "USERNAME": "Administrator", "USERDOMAIN_ROAMINGPROFILE": "EC2AMAZ-REBQJDK", "USERDOMAIN": "EC2AMAZ-REBQJDK", "TMP": "C:\Users\ADMINI~1\AppData\Local\Temp\2", "TEMP": "C:\Users\ADMINI~1\AppData\Local\Temp\2", "SystemRoot": "C:\Windows", "SystemDrive": "C:", "SESSIONNAME": "RDP-Tcp#1", "PUBLIC": "C:\Users\Public", "PSModulePath": "C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\AWS Tools\PowerShell\", "PROMPT": "$P$G", "ProgramW6432": "C:\Program Files", "ProgramFiles(x86)": "C:\Program Files (x86)", "ProgramFiles": "C:\Program Files", "ProgramData": "C:\ProgramData", "PROCESSOR_REVISION": "3f02", "PROCESSOR_LEVEL": "6", "PROCESSOR_IDENTIFIER": "Intel64 Family 6 Model 63 Stepping 2, GenuineIntel", "PROCESSOR_ARCHITECTURE": "AMD64", "PM2_USAGE": "CLI", "PM2_INTERACTOR_PROCESSING": "true", "PATHEXT": ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JSE;.WSF;.WSH;.MSC", "Path": "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Amazon\cfn-bootstrap\;C:\Program Files\nodejs\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Roaming\npm", "OS": "Windows_NT", "NUMBER_OF_PROCESSORS": "1", "LOGONSERVER": "\\EC2AMAZ-REBQJDK", "LOCALAPPDATA": "C:\Users\Administrator\AppData\Local", "HOMEPATH": "\Users\Administrator", "HOMEDRIVE": "C:", "ComSpec": "C:\Windows\system32\cmd.exe", "COMPUTERNAME": "EC2AMAZ-REBQJDK", "CommonProgramW6432": "C:\Program Files\Common Files", "CommonProgramFiles(x86)": "C:\Program Files (x86)\Common Files", "CommonProgramFiles": "C:\Program Files\Common Files", "CLIENTNAME": "THESILVERFOX", "APPDATA": "C:\Users\Administrator\AppData\Roaming", "ALLUSERSPROFILE": "C:\ProgramData", "PM2_HOME": "C:\Users\Administrator\.pm2", "status": "online", "pm_uptime": 1489390668484, "axm_actions": [], "axm_monitor": { "Loop delay": { "alert": {}, "agg_type": "avg", "value": "36.91ms" } }, "axm_options": { "default_actions": true, "transactions": false, "http": false, "http_latency": 200, "http_code": 500, "ignore_routes": [], "profiling": true, "errors": true, "alert_enabled": true, "custom_probes": true, "network": false, "ports": false, "ignoreFilter": { "method": [ "OPTIONS" ], "url": [] }, "excludedHooks": [], "module_conf": {}, "module_name": "mySuperApp", "module_version": "2.4.2", "pmx_version": "1.0.3", "error": true }, "axm_dynamic": {}, "created_at": 1489390668484, "restart_time": 0, "unstable_restarts": 0, "versioning": null, "node_version": "6.10.0" } ]



via PabloDK

No comments:

Post a Comment