-1

I have built a python script that sends users telegram notifications about things happening in their account on another service.

For this a user needs to specify API keys for said service so that my script can pull the required information.

Now currently, for a new user, I manually create a new folder on my VPS, create a new venv, a new settings file and run the application from a screen session named after the user. This is becoming tedious with 10+ users, especially with updates to the script.

I am currently building a flask based website, where users can log in and set their API keys and other parameters on a own dashboard.

What I want to achieve:

  • if user registers, a new entity of the script has to be created with a settings file next to it containing user information

  • the user should have the option to start/stop said application from the dashboard

  • if I release an update to the script I want to deploy it to all users at once and restart their script if it was running

  • basically the flask website should only act as a configuration dashboard/frontend for the script that runs on my server so that people don't need to have an own VPS or leave their private system running 24/7

How do I go about this? Is it "just" file handling, creating new folders and files from a blueprint after a user registers? Are there better practices?

I tried to find answers to that via google and the stackoverflow search but I did not find a specific recommendation for that usecase.

If anyone could point me towards a resource on that or even better an example somewhere I'd really appreciate it!

Thanks in advance.

Franz
  • 235
  • 3
  • 14

1 Answers1

1

You should have only one script and all the configurations saved into a database, then you need to dispatch some notification just pass the right parameters to the script.

justcode
  • 1,562
  • 3
  • 14
  • 25
  • Thanks for the suggestion - as the script has to watch the API of every user and react on things that change there, wouldn't stop working after a small amount of people registered? Because it will have to check every user account in serial rather having one script per user running in parallel. Assume 500 people, that's 500 api calls and answers, one after another. that could easily be 5 minutes between first and last call or am I wrong? – Franz Dec 03 '18 at 16:15
  • 1
    Just after submitting I think I see your point - build the application/script with threading/multitasking and have a thread/process created per user each cycle? – Franz Dec 03 '18 at 16:16
  • @Franz first you reduce your code to one instead of replicating it and after that if the performance of a single script isn't enough you can use multi threading. – justcode Dec 03 '18 at 19:29
  • 1
    I will try to do so. Again, thank you for your input! – Franz Dec 04 '18 at 22:47