Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using forever.js with Python

Tags:

Two questions:

  • Is there a Python equivalent to forever.js to run a Python process in the background without requiring sudo?
  • Is it possible to use forever.js with Python? How about with a virtualenv?
like image 410
robbrit Avatar asked Oct 24 '13 16:10

robbrit


People also ask

Can I use Python with Nodejs?

Note that sys is the module that allows Python to read parameters from your Node. js server, we will pass parameters from server to Python in the next examples. If nothing wrong happens, you will receive this message from the console after running your script.py using Node.

How do you make something run forever in Python?

We can create an infinite loop using while statement. If the condition of while loop is always True , we get an infinite loop.

How do you call a JavaScript file from Python?

Use ajax to Call Python From JavaScript. AJAX stands for Asynchronous JavaScript and XML. It utilizes the XMLHttpRequest object to communicate with servers. It can send and receive information in numerous formats, including HTML, XML, JSON, and text files.


1 Answers

It is easy to use Python with forever.js:

forever start -c python python_script.py 

To use it with virtualenv is a little bit more complicated, I did it using a bash script (call it python_virtualenv):

#!/bin/bash # Script to run a Python file using the local virtualenv source bin/activate bin/python $@ 

Now use that script with forever:

forever start -c ./python_virtualenv python_script.py 
like image 95
robbrit Avatar answered Sep 24 '22 03:09

robbrit