简体   繁体   English

在openshift上运行带有无限循环的简单python应用程序

[英]Running simple python app with endless loop on openshift

I'm writing small & simple telegram bot on python. 我在python上写小而简单的电报机器人。 I never used this language in my work and decided that's a good way to learn by practice. 我从未在工作中使用过这种语言,并认为这是通过练习学习的好方法。

To get updates my app currently uses long polling called from an endless loop. 为了获得更新,我的应用程序当前使用从无限循环调用的长轮询。

So I'm basically searching for the simplest way to run this app on openshift. 所以我基本上都在寻找在openshift上运行这个应用程序的最简单方法。 I tried to use this example on flask but it didn't work. 我试着在烧瓶上使用这个例子,但它没有用。 There are a lot of other options to implement background infinite processes with multiprocessing (from django and cerely to tornado) but it seems that all of them are way too advanced and complicated for my rather modest needs. 有许多其他选项可以实现多处理的背景无限过程(从django和cerely到tornado),但似乎所有这些都太过先进和复杂,因为我的需求相当苛刻。

If the polling is not event driven, then you could use 'cron' (you can add cron cartridge to your gear) to periodically trigger your python script, that does the work and "dies". 如果轮询不是事件驱动的,那么你可以使用'cron'(你可以将cron cartridge添加到你的装备中)来定期触发你的python脚本,这样就可以完成工作并“死掉”。

However, keep in mind that Openshfit is not really intended to be your worker thread (unless you are on the bronze plan or higher). 但是,请记住,Openshfit并不是真正的工作线程(除非你是青铜计划或更高版本)。 Unless you receive an external request to your gear within 24 hour period, your gear will be "idled" and your process will no longer run. 除非您在24小时内收到装备的外部请求,否则您的装备将“闲置”并且您的过程将不再运行。

The way to get around this, "officially", is probably to get the bronze plan (you will not be charged unless you require the 4th gear instance), 解决这个问题的方式,“正式”,可能是为了获得铜牌计划(除非你需要第4档实例,否则你不会被收费),

"Unofficially", you can create a gear with python that will give you a default website. “非正式”,您可以使用python创建一个可以为您提供默认网站的设备。 Then you create a new python script that does your job and trigger it using cron. 然后你创建一个新的python脚本来完成你的工作并使用cron触发它。 To keep the gear from idling, use something like uptimerobot to ping your "website" every day. 为了防止齿轮空转,请使用像uptimerobot这样的东西每天ping你的“网站”。

How do I get SSL for my domains? 如何为我的域名获取SSL?

If you are still getting by on OpenShift Online's generous Free plan, you'll see a warning message at the top of your application's SSL configuration area. 如果您仍在使用OpenShift Online慷慨的免费计划,您将在应用程序的SSL配置区域顶部看到一条警告消息。 You can always take advantage of our *.rhcloud.com wildcard certificate in order to securely connect to any application via it's original, OpenShift-provided hostname URL. 您始终可以利用我们的* .rhcloud.com通配符证书,以便通过其原始的OpenShift提供的主机名URL安全地连接到任何应用程序。

Tornado is very simple, my first steps in telegram bot dev I did using this server on openshift platform. Tornado很简单,我在电报bot开发的第一步我在openshift平台上使用这个服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM