I have a Python middleware application which polls a site for content, and then writes/updates a JSON file for a client-side web application.
I've investigated several ways for hosting this Python application on a Windows Server 2003 machine. I've set up the application to run every minute under the Windows Task Schedule, and have also looked at installing the application as a Windows Service (via NSSM).
Ideally, I'd like the application run continuously as an NSSM-managed Windows Service, with an internal task scheduler function to poll the various required sites every X seconds.
Would this be an acceptable solution? Or should I remove all polling components of the Python application, and use Windows Task Scheduling as the polling mechanism?
Related
I regularly have Python scripts that take up to 8+ hours to complete that I want to run on a remote server. However, I don't want to go through the hassle of setting up a server, setting an environment, running the script and shutting down the server after the script is done every time.
Ideally, I'm looking for a CLI product like Heroku that spins up a server, runs the script in an environment and shuts down the server after the script is done.
AWS Lambda functions sound close to what I'm looking for, but they have a runtime limit. Are there other solutions that would fit these criteria?
Thanks!
I currently have a cmd script set up on my computer in conjunction with a scheduled task that's supposed to run every 15 minutes. The script runs a python program that is also on my computer and then uploads the file that's created to my Github repository. However, this scheduled task doesn't run when my computer is completely shut down and I don't want to have my computer on 24/7.
Is there a way to run a cmd script with my computer off? I've heard of potential solutions with an Amazon Web Services account or a DigitalOcean droplet, but I'm novice (at best) with my understanding of how that works. Any suggestions or links to resources would be appreciated!
There's no way to run anything on your computer with it powered off.
You could set up a low-cost Linux VPS with any cloud compute provider (AWS, DigitalOcean, Microsoft Azure, Google Cloud Platform, Vultr, etc.), migrate your python program to it, and schedule that program to run every 15 minutes on there.
DigitalOcean: How to set up an Ubuntu 20.04 server
You would need to keep that VPS turned on, and in place of Task Scheduler, you could schedule your Python program to run (with any arguments) as a cron job.
DigitalOcean: How to use Cron to automate tasks
I have set up a Laravel app in windows server 2012 but want to run jobs in it as windows services. So that it is always running on my server. I want my users to access it as a website publicly from any browser.
Also, I would like to know how can I use python to perform crud operations as a service hosted on the same server.
You can run supervisor on your OS and mange your jobs.
how to install supervisor on windows server
The other solution is Non-Sucking Service Manager that help you run your queue process as windows service.
Please check this question on Laracast.com
I have a task written in Python with a 1-2 minute run-time that I want to run on-demand. The requests would come In very small volumes from a Django server on Linux. The return would be a file.
Usually, I'd use a queue system like Celery. But, this task can only be run on Windows.
What is the best way to make this happen?
Remotely execute the task by establishing an SSH session?
Still use Celery, go through a lot of workarounds to get it to work on Windows (seems messy)?
I could think of 5 solutions which do not require ssh
I didn't talk about authentication in my solutions you should implement something based on chosen solution
Solution 1:
write a simple flask/django app for windows server which runs the task and returns response
in your linux server send a request to windows and get data
linux server can make this call using celery so you wouldn't bother about 2/3 minute wait
Solution 2:
write a simple flask/django app for windows server which calls a celery task in back ground
this app should return the url of result file
celery task creates a file which contains the result
serve this file with nginx (or a windows based static file server, I don't know windows)
send a request from linux server to windows to get result (if file doesn't exists it means result is not ready yet)
Solution 3:
write a simple flask/django app for windows server which calls a celery task in back ground
this app returns a random id for given request
from your linux server send requests to windows app with task id
when task is finished windows app returns result
Solution 4:
write a simple flask/django app for windows server which calls a celery task in back ground
add an endpoint to your linux django app for uploading data
when windows app finishes processing it uploads data to linux django app
Solution 5:
solution 4 but your linux django app is not for uploading data. it only sets a boolean which mean task is done
if task is done linux server send a request to winsows server to get data (this request contains the task id)
The idea:
There is a Node.JS server which sends a request to the IIS server which is running Django / Python. It will send two files to the server which need to be converted with a program which needs to be run in the foreground mode.
So I already looked around in pretty much everything related to IIS and the running of executables here on SO, but still haven't got it working.
I got the following code to run the application from Django:
subprocess.call("C:\example.exe")
There will be probably be some serious security issues (although the server is only reachable from the local network) with the following setup, but here it is:
I'm running a Django application on IIS.
I've set the Application Pool Identity to my local user
I've given "Full Control" permission to "Everyone"
When the subprocess call gets executed it will add the program to my Background Processes with the USER being set to my local user.
Questions:
How do I make the program start in Desktop Mode?
Should I perhaps add another step (start another service) which will then start the program?
Edit:
Could I perhaps make a file watcher which watches if files get stored on the Windows Server and then triggers an executable based on that?