python script works but heroku crashs











up vote
0
down vote

favorite












I am building an app for my dad which scraps the lotto results (beautifulsoup) and send them via email (sendgrid). I use heroku to run the script github repo on a scheduled basis. If I run it, it will work fine. The emails will be sent but the process crash's which restarts them because of the dyno restart policy. The crash isn't that bad because the script will do its job but the problem is the restart of the dyno, which leads to many emails sent. You will find the script in my repo.



My guess is the asynchronicity with beautiful soup and/or sendgrid. Do you know how to get better log information in heroku? If I comment out the actual email sending part and start the scheduler on ten minutes then it works but the worker doesn't.



My Procfile looks like:



worker: python lotto_mailer.py


Here is the server log.



Nov 19 05:56:36 lotto-mailer heroku/scheduler.2285: Starting process with command `if [ "$(date +%u)" = 1 ]; then python lotto_mailer.py; fi` 
Nov 19 05:56:37 lotto-mailer heroku/scheduler.2285: State changed from starting to up
Nov 19 05:56:40 lotto-mailer heroku/scheduler.2285: State changed from up to complete
Nov 19 05:56:40 lotto-mailer heroku/scheduler.2285: Process exited with status 0
Nov 19 05:56:41 lotto-mailer app/scheduler.2285: Ziehung vom Samstag, 17.11.2018
Nov 19 05:56:41 lotto-mailer app/scheduler.2285: Gewinnzahlen: [3, 6, 18, 31, 39, 40] SZ: 5
... App OUTPUT ...
Nov 19 05:56:41 lotto-mailer app/scheduler.2285: UTC Hour: 13


Don't get distracted by the command which the scheduler runs. It's just to run it only on mondays. It seems that only the worker crashs not the scheduler.



Nov 19 06:04:24 lotto-mailer heroku/worker.1: State changed from crashed to starting 
Nov 19 06:04:29 lotto-mailer heroku/worker.1: Starting process with command `python lotto_mailer.py`
Nov 19 06:04:29 lotto-mailer heroku/worker.1: State changed from starting to up
Nov 19 06:04:29 lotto-mailer heroku/worker.1: State changed from crashed to starting
Nov 19 06:04:32 lotto-mailer heroku/worker.1: State changed from up to crashed
Nov 19 06:04:33 lotto-mailer heroku/worker.1: Process exited with status 0
Nov 19 06:04:33 lotto-mailer app/worker.1: Ziehung vom Samstag, 17.11.2018
Nov 19 06:04:33 lotto-mailer app/worker.1: Gewinnzahlen: [3, 6, 18, 31, 39, 40] SZ: 5
... APP OUTPUT ...


Why does the worker run at all? If you need further information, just let me now. Thank you for your help.



solution: I have recognized that I can deactivate the worker
here
and just let the scheduler run but the question remains, why does the worker crash.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I am building an app for my dad which scraps the lotto results (beautifulsoup) and send them via email (sendgrid). I use heroku to run the script github repo on a scheduled basis. If I run it, it will work fine. The emails will be sent but the process crash's which restarts them because of the dyno restart policy. The crash isn't that bad because the script will do its job but the problem is the restart of the dyno, which leads to many emails sent. You will find the script in my repo.



    My guess is the asynchronicity with beautiful soup and/or sendgrid. Do you know how to get better log information in heroku? If I comment out the actual email sending part and start the scheduler on ten minutes then it works but the worker doesn't.



    My Procfile looks like:



    worker: python lotto_mailer.py


    Here is the server log.



    Nov 19 05:56:36 lotto-mailer heroku/scheduler.2285: Starting process with command `if [ "$(date +%u)" = 1 ]; then python lotto_mailer.py; fi` 
    Nov 19 05:56:37 lotto-mailer heroku/scheduler.2285: State changed from starting to up
    Nov 19 05:56:40 lotto-mailer heroku/scheduler.2285: State changed from up to complete
    Nov 19 05:56:40 lotto-mailer heroku/scheduler.2285: Process exited with status 0
    Nov 19 05:56:41 lotto-mailer app/scheduler.2285: Ziehung vom Samstag, 17.11.2018
    Nov 19 05:56:41 lotto-mailer app/scheduler.2285: Gewinnzahlen: [3, 6, 18, 31, 39, 40] SZ: 5
    ... App OUTPUT ...
    Nov 19 05:56:41 lotto-mailer app/scheduler.2285: UTC Hour: 13


    Don't get distracted by the command which the scheduler runs. It's just to run it only on mondays. It seems that only the worker crashs not the scheduler.



    Nov 19 06:04:24 lotto-mailer heroku/worker.1: State changed from crashed to starting 
    Nov 19 06:04:29 lotto-mailer heroku/worker.1: Starting process with command `python lotto_mailer.py`
    Nov 19 06:04:29 lotto-mailer heroku/worker.1: State changed from starting to up
    Nov 19 06:04:29 lotto-mailer heroku/worker.1: State changed from crashed to starting
    Nov 19 06:04:32 lotto-mailer heroku/worker.1: State changed from up to crashed
    Nov 19 06:04:33 lotto-mailer heroku/worker.1: Process exited with status 0
    Nov 19 06:04:33 lotto-mailer app/worker.1: Ziehung vom Samstag, 17.11.2018
    Nov 19 06:04:33 lotto-mailer app/worker.1: Gewinnzahlen: [3, 6, 18, 31, 39, 40] SZ: 5
    ... APP OUTPUT ...


    Why does the worker run at all? If you need further information, just let me now. Thank you for your help.



    solution: I have recognized that I can deactivate the worker
    here
    and just let the scheduler run but the question remains, why does the worker crash.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am building an app for my dad which scraps the lotto results (beautifulsoup) and send them via email (sendgrid). I use heroku to run the script github repo on a scheduled basis. If I run it, it will work fine. The emails will be sent but the process crash's which restarts them because of the dyno restart policy. The crash isn't that bad because the script will do its job but the problem is the restart of the dyno, which leads to many emails sent. You will find the script in my repo.



      My guess is the asynchronicity with beautiful soup and/or sendgrid. Do you know how to get better log information in heroku? If I comment out the actual email sending part and start the scheduler on ten minutes then it works but the worker doesn't.



      My Procfile looks like:



      worker: python lotto_mailer.py


      Here is the server log.



      Nov 19 05:56:36 lotto-mailer heroku/scheduler.2285: Starting process with command `if [ "$(date +%u)" = 1 ]; then python lotto_mailer.py; fi` 
      Nov 19 05:56:37 lotto-mailer heroku/scheduler.2285: State changed from starting to up
      Nov 19 05:56:40 lotto-mailer heroku/scheduler.2285: State changed from up to complete
      Nov 19 05:56:40 lotto-mailer heroku/scheduler.2285: Process exited with status 0
      Nov 19 05:56:41 lotto-mailer app/scheduler.2285: Ziehung vom Samstag, 17.11.2018
      Nov 19 05:56:41 lotto-mailer app/scheduler.2285: Gewinnzahlen: [3, 6, 18, 31, 39, 40] SZ: 5
      ... App OUTPUT ...
      Nov 19 05:56:41 lotto-mailer app/scheduler.2285: UTC Hour: 13


      Don't get distracted by the command which the scheduler runs. It's just to run it only on mondays. It seems that only the worker crashs not the scheduler.



      Nov 19 06:04:24 lotto-mailer heroku/worker.1: State changed from crashed to starting 
      Nov 19 06:04:29 lotto-mailer heroku/worker.1: Starting process with command `python lotto_mailer.py`
      Nov 19 06:04:29 lotto-mailer heroku/worker.1: State changed from starting to up
      Nov 19 06:04:29 lotto-mailer heroku/worker.1: State changed from crashed to starting
      Nov 19 06:04:32 lotto-mailer heroku/worker.1: State changed from up to crashed
      Nov 19 06:04:33 lotto-mailer heroku/worker.1: Process exited with status 0
      Nov 19 06:04:33 lotto-mailer app/worker.1: Ziehung vom Samstag, 17.11.2018
      Nov 19 06:04:33 lotto-mailer app/worker.1: Gewinnzahlen: [3, 6, 18, 31, 39, 40] SZ: 5
      ... APP OUTPUT ...


      Why does the worker run at all? If you need further information, just let me now. Thank you for your help.



      solution: I have recognized that I can deactivate the worker
      here
      and just let the scheduler run but the question remains, why does the worker crash.










      share|improve this question















      I am building an app for my dad which scraps the lotto results (beautifulsoup) and send them via email (sendgrid). I use heroku to run the script github repo on a scheduled basis. If I run it, it will work fine. The emails will be sent but the process crash's which restarts them because of the dyno restart policy. The crash isn't that bad because the script will do its job but the problem is the restart of the dyno, which leads to many emails sent. You will find the script in my repo.



      My guess is the asynchronicity with beautiful soup and/or sendgrid. Do you know how to get better log information in heroku? If I comment out the actual email sending part and start the scheduler on ten minutes then it works but the worker doesn't.



      My Procfile looks like:



      worker: python lotto_mailer.py


      Here is the server log.



      Nov 19 05:56:36 lotto-mailer heroku/scheduler.2285: Starting process with command `if [ "$(date +%u)" = 1 ]; then python lotto_mailer.py; fi` 
      Nov 19 05:56:37 lotto-mailer heroku/scheduler.2285: State changed from starting to up
      Nov 19 05:56:40 lotto-mailer heroku/scheduler.2285: State changed from up to complete
      Nov 19 05:56:40 lotto-mailer heroku/scheduler.2285: Process exited with status 0
      Nov 19 05:56:41 lotto-mailer app/scheduler.2285: Ziehung vom Samstag, 17.11.2018
      Nov 19 05:56:41 lotto-mailer app/scheduler.2285: Gewinnzahlen: [3, 6, 18, 31, 39, 40] SZ: 5
      ... App OUTPUT ...
      Nov 19 05:56:41 lotto-mailer app/scheduler.2285: UTC Hour: 13


      Don't get distracted by the command which the scheduler runs. It's just to run it only on mondays. It seems that only the worker crashs not the scheduler.



      Nov 19 06:04:24 lotto-mailer heroku/worker.1: State changed from crashed to starting 
      Nov 19 06:04:29 lotto-mailer heroku/worker.1: Starting process with command `python lotto_mailer.py`
      Nov 19 06:04:29 lotto-mailer heroku/worker.1: State changed from starting to up
      Nov 19 06:04:29 lotto-mailer heroku/worker.1: State changed from crashed to starting
      Nov 19 06:04:32 lotto-mailer heroku/worker.1: State changed from up to crashed
      Nov 19 06:04:33 lotto-mailer heroku/worker.1: Process exited with status 0
      Nov 19 06:04:33 lotto-mailer app/worker.1: Ziehung vom Samstag, 17.11.2018
      Nov 19 06:04:33 lotto-mailer app/worker.1: Gewinnzahlen: [3, 6, 18, 31, 39, 40] SZ: 5
      ... APP OUTPUT ...


      Why does the worker run at all? If you need further information, just let me now. Thank you for your help.



      solution: I have recognized that I can deactivate the worker
      here
      and just let the scheduler run but the question remains, why does the worker crash.







      python heroku beautifulsoup sendgrid






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 at 14:29

























      asked Nov 19 at 14:21









      Algore87

      87




      87
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          worker is for web service/server not CLI app this is why it crash and you receive many email because it will auto restart if crash. worker is not required you can delete Procfile or maybe create dummy server that actually scheduler using while and sleep.






          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',
            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%2f53376621%2fpython-script-works-but-heroku-crashs%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








            up vote
            0
            down vote













            worker is for web service/server not CLI app this is why it crash and you receive many email because it will auto restart if crash. worker is not required you can delete Procfile or maybe create dummy server that actually scheduler using while and sleep.






            share|improve this answer

























              up vote
              0
              down vote













              worker is for web service/server not CLI app this is why it crash and you receive many email because it will auto restart if crash. worker is not required you can delete Procfile or maybe create dummy server that actually scheduler using while and sleep.






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                worker is for web service/server not CLI app this is why it crash and you receive many email because it will auto restart if crash. worker is not required you can delete Procfile or maybe create dummy server that actually scheduler using while and sleep.






                share|improve this answer












                worker is for web service/server not CLI app this is why it crash and you receive many email because it will auto restart if crash. worker is not required you can delete Procfile or maybe create dummy server that actually scheduler using while and sleep.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 19 at 16:44









                ewwink

                6,50122233




                6,50122233






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376621%2fpython-script-works-but-heroku-crashs%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

                    Wiesbaden

                    To store a contact into the json file from server.js file using a class in NodeJS

                    Marschland