Running a Python script in Conda virtual environment as service

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I recently wrote a Python program that is designed to communicate via SMPP SMS server.



The issue I'm facing is that I don't know how to run a Python script as a service on my Cent OS server using Conda virtual environment. I'm using a lot of dependencies and choosing virtual environment over Conda is not an option.



Is there any way I could run this script as a service? Also is there a way to write console methods to start this script using the following?



service fooService start









share|improve this question



























    up vote
    1
    down vote

    favorite












    I recently wrote a Python program that is designed to communicate via SMPP SMS server.



    The issue I'm facing is that I don't know how to run a Python script as a service on my Cent OS server using Conda virtual environment. I'm using a lot of dependencies and choosing virtual environment over Conda is not an option.



    Is there any way I could run this script as a service? Also is there a way to write console methods to start this script using the following?



    service fooService start









    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I recently wrote a Python program that is designed to communicate via SMPP SMS server.



      The issue I'm facing is that I don't know how to run a Python script as a service on my Cent OS server using Conda virtual environment. I'm using a lot of dependencies and choosing virtual environment over Conda is not an option.



      Is there any way I could run this script as a service? Also is there a way to write console methods to start this script using the following?



      service fooService start









      share|improve this question















      I recently wrote a Python program that is designed to communicate via SMPP SMS server.



      The issue I'm facing is that I don't know how to run a Python script as a service on my Cent OS server using Conda virtual environment. I'm using a lot of dependencies and choosing virtual environment over Conda is not an option.



      Is there any way I could run this script as a service? Also is there a way to write console methods to start this script using the following?



      service fooService start






      python services anaconda start-stop-daemon virtualenv






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 27 '16 at 14:43









      Tomasz

      8,30552560




      8,30552560










      asked Jul 29 '16 at 22:43









      David Swan

      1112




      1112




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          Sorry this comes late, but the way to run a python script within a particular environment is to write a shell script like this:



          #!/bin/bash
          source activate my_env && python my_script.py


          and have that wrapper script as your service instead of the python script itself.






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            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: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f299192%2frunning-a-python-script-in-conda-virtual-environment-as-service%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote













            Sorry this comes late, but the way to run a python script within a particular environment is to write a shell script like this:



            #!/bin/bash
            source activate my_env && python my_script.py


            and have that wrapper script as your service instead of the python script itself.






            share|improve this answer
























              up vote
              1
              down vote













              Sorry this comes late, but the way to run a python script within a particular environment is to write a shell script like this:



              #!/bin/bash
              source activate my_env && python my_script.py


              and have that wrapper script as your service instead of the python script itself.






              share|improve this answer






















                up vote
                1
                down vote










                up vote
                1
                down vote









                Sorry this comes late, but the way to run a python script within a particular environment is to write a shell script like this:



                #!/bin/bash
                source activate my_env && python my_script.py


                and have that wrapper script as your service instead of the python script itself.






                share|improve this answer












                Sorry this comes late, but the way to run a python script within a particular environment is to write a shell script like this:



                #!/bin/bash
                source activate my_env && python my_script.py


                and have that wrapper script as your service instead of the python script itself.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 10 '16 at 18:57









                Tunisia

                111




                111



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f299192%2frunning-a-python-script-in-conda-virtual-environment-as-service%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Peggy Mitchell

                    Palaiologos

                    The Forum (Inglewood, California)