问题描述
我是新来的Android。我有一个Python程序,既是一个CGI脚本以及用于小型数据库的基于短信交互系统。这是一个非常低的点播系统(少数用户)由一个基层组织运行。但是,它需要的稳定性,在不具有随机崩溃或停机时间的感觉。由于种种原因,在Android手机上运行,这将解决一些问题与现有的设置。然而,在我潜水,我想检查对这样一个系统的可行性。它必须:
I'm new to Android. I have a Python program that is both a CGI script as well as an SMS-based interaction system for a small database. It is an extremely low demand system (a handful of users) being run by a grassroots organisation. But it requires stability, in the sense of not having random crashes or down time. For various reasons, running this on an Android phone would resolve some problems with the existing setup. However, before I dive in, I wanted to check regarding the feasibility of such a system. It would have to:
- 运行一个Web服务器,可以执行CGI脚本(香草CGI)
- 回复短信
- 处理SQLite数据库
- 在Python中这样做(因为它移植到Java是不可行的,由于时间限制)
与电话用户接口不要求在此阶段
Interfacing with phone users is not required at this stage.
我知道,这将需要的作品存在 - 的等,但在Web服务器的Android /> Web服务器似乎大多用于个人使用,SL4A明确指出它。对SO有关SL4A各种说太多关于这种用例。他们专注于应用开发的手机(如this 之一)。
I am aware that the pieces that would be needed exist - web servers with CGI, SL4A, etc. But the webservers mostly seem intended for personal use and SL4A clearly states that it "is alpha quality software". The various questions on SO relating to SL4A also don't seem to say much on this kind of use case. They are focused on application development for phones (such as this one).
在短期,将这样的系统是稳定的?假设的核心程序是健全的,我能靠什么呢?
In short, would such a system be stable? Assuming the core program is sound, could I rely on it?
推荐答案
TLDR :CherryPy的是一个可靠的服务器,而Android可能足够可靠在这些天建立服务器
TLDR: CherryPy is a dependable server, and Android may be dependable enough to build servers on these days.
我用来维护其使用的CherryPy和SL4A,与ws4py对WebSockets的一个项目。
I used to maintain a project which used CherryPy and SL4A, with ws4py for websockets.
3.2.2的CherryPy工作完全关于Python 2.6和Python 3.2。
CherryPy 3.2.2 worked perfectly on Python 2.6 and Python 3.2.
应用程序往往运行了两天。这似乎是它会一直很好,如果它跑更长的时间,但它得到重新启动了很多,因为它是正在开发中。
The application was often running for a day or two. It seemed like it would have been fine if it ran longer, but it got restarted a lot as it was being developed.
CherryPy的总是好的,但Android设备做有时只是崩溃,所以SL4A将时间退回到时间,需要重新启动。这可能不是只用作服务器的设备上的问题。对我来说,它一直是稳定留下了设备运行时一夜之间,但是当我用的是设备正常(这是我的实际电话)偶尔会崩溃。所有这一切都是在GALAXY SII,回来时的Android仍然是pretty越野车那样的。
CherryPy was always fine, but Android devices do sometimes just crash, so SL4A will exit from time to time, and need to be restarted. This may not be an issue on a device that was only used as a server. For me, it was always stable when the device was left running overnight, but would occasionally crash when I was using the device normally (it was my actual phone). All of this was on a Galaxy SII, back when Android was still pretty buggy like that.
设置CherryPy的很容易。它是纯Python,所以你能把一个副本到您的路径一些地方和导入(你并不需要一个模拟器其一)。
Setting up CherryPy is easy. It is pure Python, so you can just drop a copy onto your path some place and import it (you do not need an emulator either).
您可能很难保持清醒的设备。如果它被单独留在家中,它会进入睡眠状态。你可以告诉它留在开发人员选项清醒,但我pretty确保只有当设备充电工作。
You may struggle to keep the device awake. If it is left alone, it will go to sleep. You can tell it to stay awake in the developer options, but I am pretty sure that only works if the device is charging.
的更新的:Android是要稳定得多,现在天,但对SL4A项目工作有pretty多结束。有一个叫QPython项目,保持一个副本作为一个更大的应用程序的一部分,所以它仍然可以轻松完成。
UPDATE: Android is much more stable now days, but work on the SL4A project has pretty much ended. There's a project called QPython that maintains a copy as part of a bigger app, so it can still be done easily.
这篇关于运行Android手机作为一个稳定的网络服务器(用于一个Python CGI脚本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!