pm2 reload ecosystem.config.js causing many restarts on application












0














I am experiencing problems reloading the application using the ecosystem.config.js file. When the application is started for the first time, it starts correctly, but when I refresh/reload the application using the ecosystem.config.js file, the application restarts several times causing an error.



My SO is Ubuntu Xenial, PM2 version is 3.2.2 and Node v10.13.0. The application uses the latest version from Express module (4.16.4).
If I reload the application with "pm2 reload app_name", this problem doesn't occur.



The ecosystem.config.js content:



module.exports = {
apps: [{
script: "./index.js",
instances: "max",
exec_mode: "cluster",
kill_timeout: "2000",
env: {
NODE_ENV: "development",
},
env_production: {
NODE_ENV: "production",
}
}]
}


When I run the first time:




$ pm2 reload ecosystem.config.js



[PM2][WARN] Applications index not running, starting...



[PM2] App [index] launched (2 instances)



node@ubuntu:/data/$ pm2 logs



[TAILING] Tailing last 15 lines for [all] processes (change the value with >--lines option)



/home/node/.pm2/pm2.log last 15 lines:



PM2 | 2018-11-23T13:14:30: PM2 log: App [index:0] starting in -cluster >mode-



PM2 | 2018-11-23T13:14:31: PM2 log: App [index:0] online



PM2 | 2018-11-23T13:14:31: PM2 log: App [index:1] starting in -cluster >mode-



PM2 | 2018-11-23T13:14:31: PM2 log: App [index:1] online




When I reload the application by name (ex: pm2 reload app_name), the application contiue runnig, but I see some timeouts to kill process:



PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=failed to kill - retrying in 100ms
PM2 | 2018-11-23T14:01:02: PM2 log: Process with pid 11289 still alive after 6000ms, sending it SIGKILL now...
PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=failed to kill - retrying in 100ms
PM2 | 2018-11-23T14:01:02: PM2 log: Process with pid 11296 still alive after 6000ms, sending it SIGKILL now...
PM2 | 2018-11-23T14:01:02: PM2 log: App name:index id:_old_0 disconnected
PM2 | 2018-11-23T14:01:02: PM2 log: App [index:_old_0] exited with code [0] via signal [SIGKILL]
PM2 | 2018-11-23T14:01:02: PM2 log: App name:index id:_old_1 disconnected
PM2 | 2018-11-23T14:01:02: PM2 log: App [index:_old_1] exited with code [0] via signal [SIGKILL]
PM2 | 2018-11-23T14:01:02: PM2 log: pid=11289 msg=process killed
PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=process killed



But, even though timeouts occur the application is running.



When I execute "pm2 reload ecosystem.config.js", the PM2 restart the application several times and one instance fail:




0|index | at Module.load (internal/modules/cjs/loader.js:598:32)



0|index | at tryModuleLoad (internal/modules/cjs/loader.js:537:12)



0|index | at Function.Module._load (internal/modules/cjs/loader.js:529:3)



0|index | at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:48:21)



0|index | Error: listen EADDRINUSE :::3001




I believe the problem is related to some timeout to properly terminate the http connection of the Express module, but I'm still investigating this.










share|improve this question





























    0














    I am experiencing problems reloading the application using the ecosystem.config.js file. When the application is started for the first time, it starts correctly, but when I refresh/reload the application using the ecosystem.config.js file, the application restarts several times causing an error.



    My SO is Ubuntu Xenial, PM2 version is 3.2.2 and Node v10.13.0. The application uses the latest version from Express module (4.16.4).
    If I reload the application with "pm2 reload app_name", this problem doesn't occur.



    The ecosystem.config.js content:



    module.exports = {
    apps: [{
    script: "./index.js",
    instances: "max",
    exec_mode: "cluster",
    kill_timeout: "2000",
    env: {
    NODE_ENV: "development",
    },
    env_production: {
    NODE_ENV: "production",
    }
    }]
    }


    When I run the first time:




    $ pm2 reload ecosystem.config.js



    [PM2][WARN] Applications index not running, starting...



    [PM2] App [index] launched (2 instances)



    node@ubuntu:/data/$ pm2 logs



    [TAILING] Tailing last 15 lines for [all] processes (change the value with >--lines option)



    /home/node/.pm2/pm2.log last 15 lines:



    PM2 | 2018-11-23T13:14:30: PM2 log: App [index:0] starting in -cluster >mode-



    PM2 | 2018-11-23T13:14:31: PM2 log: App [index:0] online



    PM2 | 2018-11-23T13:14:31: PM2 log: App [index:1] starting in -cluster >mode-



    PM2 | 2018-11-23T13:14:31: PM2 log: App [index:1] online




    When I reload the application by name (ex: pm2 reload app_name), the application contiue runnig, but I see some timeouts to kill process:



    PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=failed to kill - retrying in 100ms
    PM2 | 2018-11-23T14:01:02: PM2 log: Process with pid 11289 still alive after 6000ms, sending it SIGKILL now...
    PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=failed to kill - retrying in 100ms
    PM2 | 2018-11-23T14:01:02: PM2 log: Process with pid 11296 still alive after 6000ms, sending it SIGKILL now...
    PM2 | 2018-11-23T14:01:02: PM2 log: App name:index id:_old_0 disconnected
    PM2 | 2018-11-23T14:01:02: PM2 log: App [index:_old_0] exited with code [0] via signal [SIGKILL]
    PM2 | 2018-11-23T14:01:02: PM2 log: App name:index id:_old_1 disconnected
    PM2 | 2018-11-23T14:01:02: PM2 log: App [index:_old_1] exited with code [0] via signal [SIGKILL]
    PM2 | 2018-11-23T14:01:02: PM2 log: pid=11289 msg=process killed
    PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=process killed



    But, even though timeouts occur the application is running.



    When I execute "pm2 reload ecosystem.config.js", the PM2 restart the application several times and one instance fail:




    0|index | at Module.load (internal/modules/cjs/loader.js:598:32)



    0|index | at tryModuleLoad (internal/modules/cjs/loader.js:537:12)



    0|index | at Function.Module._load (internal/modules/cjs/loader.js:529:3)



    0|index | at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:48:21)



    0|index | Error: listen EADDRINUSE :::3001




    I believe the problem is related to some timeout to properly terminate the http connection of the Express module, but I'm still investigating this.










    share|improve this question



























      0












      0








      0







      I am experiencing problems reloading the application using the ecosystem.config.js file. When the application is started for the first time, it starts correctly, but when I refresh/reload the application using the ecosystem.config.js file, the application restarts several times causing an error.



      My SO is Ubuntu Xenial, PM2 version is 3.2.2 and Node v10.13.0. The application uses the latest version from Express module (4.16.4).
      If I reload the application with "pm2 reload app_name", this problem doesn't occur.



      The ecosystem.config.js content:



      module.exports = {
      apps: [{
      script: "./index.js",
      instances: "max",
      exec_mode: "cluster",
      kill_timeout: "2000",
      env: {
      NODE_ENV: "development",
      },
      env_production: {
      NODE_ENV: "production",
      }
      }]
      }


      When I run the first time:




      $ pm2 reload ecosystem.config.js



      [PM2][WARN] Applications index not running, starting...



      [PM2] App [index] launched (2 instances)



      node@ubuntu:/data/$ pm2 logs



      [TAILING] Tailing last 15 lines for [all] processes (change the value with >--lines option)



      /home/node/.pm2/pm2.log last 15 lines:



      PM2 | 2018-11-23T13:14:30: PM2 log: App [index:0] starting in -cluster >mode-



      PM2 | 2018-11-23T13:14:31: PM2 log: App [index:0] online



      PM2 | 2018-11-23T13:14:31: PM2 log: App [index:1] starting in -cluster >mode-



      PM2 | 2018-11-23T13:14:31: PM2 log: App [index:1] online




      When I reload the application by name (ex: pm2 reload app_name), the application contiue runnig, but I see some timeouts to kill process:



      PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=failed to kill - retrying in 100ms
      PM2 | 2018-11-23T14:01:02: PM2 log: Process with pid 11289 still alive after 6000ms, sending it SIGKILL now...
      PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=failed to kill - retrying in 100ms
      PM2 | 2018-11-23T14:01:02: PM2 log: Process with pid 11296 still alive after 6000ms, sending it SIGKILL now...
      PM2 | 2018-11-23T14:01:02: PM2 log: App name:index id:_old_0 disconnected
      PM2 | 2018-11-23T14:01:02: PM2 log: App [index:_old_0] exited with code [0] via signal [SIGKILL]
      PM2 | 2018-11-23T14:01:02: PM2 log: App name:index id:_old_1 disconnected
      PM2 | 2018-11-23T14:01:02: PM2 log: App [index:_old_1] exited with code [0] via signal [SIGKILL]
      PM2 | 2018-11-23T14:01:02: PM2 log: pid=11289 msg=process killed
      PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=process killed



      But, even though timeouts occur the application is running.



      When I execute "pm2 reload ecosystem.config.js", the PM2 restart the application several times and one instance fail:




      0|index | at Module.load (internal/modules/cjs/loader.js:598:32)



      0|index | at tryModuleLoad (internal/modules/cjs/loader.js:537:12)



      0|index | at Function.Module._load (internal/modules/cjs/loader.js:529:3)



      0|index | at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:48:21)



      0|index | Error: listen EADDRINUSE :::3001




      I believe the problem is related to some timeout to properly terminate the http connection of the Express module, but I'm still investigating this.










      share|improve this question















      I am experiencing problems reloading the application using the ecosystem.config.js file. When the application is started for the first time, it starts correctly, but when I refresh/reload the application using the ecosystem.config.js file, the application restarts several times causing an error.



      My SO is Ubuntu Xenial, PM2 version is 3.2.2 and Node v10.13.0. The application uses the latest version from Express module (4.16.4).
      If I reload the application with "pm2 reload app_name", this problem doesn't occur.



      The ecosystem.config.js content:



      module.exports = {
      apps: [{
      script: "./index.js",
      instances: "max",
      exec_mode: "cluster",
      kill_timeout: "2000",
      env: {
      NODE_ENV: "development",
      },
      env_production: {
      NODE_ENV: "production",
      }
      }]
      }


      When I run the first time:




      $ pm2 reload ecosystem.config.js



      [PM2][WARN] Applications index not running, starting...



      [PM2] App [index] launched (2 instances)



      node@ubuntu:/data/$ pm2 logs



      [TAILING] Tailing last 15 lines for [all] processes (change the value with >--lines option)



      /home/node/.pm2/pm2.log last 15 lines:



      PM2 | 2018-11-23T13:14:30: PM2 log: App [index:0] starting in -cluster >mode-



      PM2 | 2018-11-23T13:14:31: PM2 log: App [index:0] online



      PM2 | 2018-11-23T13:14:31: PM2 log: App [index:1] starting in -cluster >mode-



      PM2 | 2018-11-23T13:14:31: PM2 log: App [index:1] online




      When I reload the application by name (ex: pm2 reload app_name), the application contiue runnig, but I see some timeouts to kill process:



      PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=failed to kill - retrying in 100ms
      PM2 | 2018-11-23T14:01:02: PM2 log: Process with pid 11289 still alive after 6000ms, sending it SIGKILL now...
      PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=failed to kill - retrying in 100ms
      PM2 | 2018-11-23T14:01:02: PM2 log: Process with pid 11296 still alive after 6000ms, sending it SIGKILL now...
      PM2 | 2018-11-23T14:01:02: PM2 log: App name:index id:_old_0 disconnected
      PM2 | 2018-11-23T14:01:02: PM2 log: App [index:_old_0] exited with code [0] via signal [SIGKILL]
      PM2 | 2018-11-23T14:01:02: PM2 log: App name:index id:_old_1 disconnected
      PM2 | 2018-11-23T14:01:02: PM2 log: App [index:_old_1] exited with code [0] via signal [SIGKILL]
      PM2 | 2018-11-23T14:01:02: PM2 log: pid=11289 msg=process killed
      PM2 | 2018-11-23T14:01:02: PM2 log: pid=11296 msg=process killed



      But, even though timeouts occur the application is running.



      When I execute "pm2 reload ecosystem.config.js", the PM2 restart the application several times and one instance fail:




      0|index | at Module.load (internal/modules/cjs/loader.js:598:32)



      0|index | at tryModuleLoad (internal/modules/cjs/loader.js:537:12)



      0|index | at Function.Module._load (internal/modules/cjs/loader.js:529:3)



      0|index | at Object. (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:48:21)



      0|index | Error: listen EADDRINUSE :::3001




      I believe the problem is related to some timeout to properly terminate the http connection of the Express module, but I'm still investigating this.







      node.js express pm2






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 '18 at 16:02









      iLuvLogix

      1,154421




      1,154421










      asked Nov 23 '18 at 14:30









      Rodrigo de Lima Silva

      11




      11
























          1 Answer
          1






          active

          oldest

          votes


















          0














          It has been fixed on the lastest PM2 version, please update:



          npm install pm2@latest -g
          pm2 update



          Make sure you pm2 delete all and then start back your application again, it will work then when doing reload or restart






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53448550%2fpm2-reload-ecosystem-config-js-causing-many-restarts-on-application%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            It has been fixed on the lastest PM2 version, please update:



            npm install pm2@latest -g
            pm2 update



            Make sure you pm2 delete all and then start back your application again, it will work then when doing reload or restart






            share|improve this answer


























              0














              It has been fixed on the lastest PM2 version, please update:



              npm install pm2@latest -g
              pm2 update



              Make sure you pm2 delete all and then start back your application again, it will work then when doing reload or restart






              share|improve this answer
























                0












                0








                0






                It has been fixed on the lastest PM2 version, please update:



                npm install pm2@latest -g
                pm2 update



                Make sure you pm2 delete all and then start back your application again, it will work then when doing reload or restart






                share|improve this answer












                It has been fixed on the lastest PM2 version, please update:



                npm install pm2@latest -g
                pm2 update



                Make sure you pm2 delete all and then start back your application again, it will work then when doing reload or restart







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 13 '18 at 17:26









                Unitech

                2,80933141




                2,80933141






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53448550%2fpm2-reload-ecosystem-config-js-causing-many-restarts-on-application%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

                    Calculate evaluation metrics using cross_val_predict sklearn

                    Insert data from modal to MySQL (multiple modal on website)