1

I have a modest CherryPy / SQLite application under development. I would like to put it on a server in the cloud for client testing. Towards that end I've spun up a small Ubuntu instance at Rackspace and done some preliminary installation (setup-tools and CherryPy).

Not being either an administrator or particularly familiar with Linux I have some rather simple questions about deploying this application that I haven't been able to answer using Google:

  1. I assume I should create a user account specifically to run the application rather than using root or any other existing account?

  2. I'm not sure where I should transplant my application folders. I'm guessing that they should go in /usr/user-I-created-question-1/. Is that correct?

  3. I'm using the CherryPy server which appears to be sufficient to my needs for this application. Is the correct approach to start the application in a putty session then kill the putty session on my Windows machine?

  4. Aside from visiting the site myself, what tools or techniques exist to monitor up-time, or to know if the server has become unavailable?

1 Answer 1

2

You know, if it's only for testing for a limited amount of time, it's probably fine running the way you are talking about. Though it's probably also fine, under those circumstances, to run as any user. It's probably best to create a non-privileged user and have it run under that.

Where do you put it? Probably in a sub-directory of that users' home directory, like "/home/username/mywebapp".

You will probably want to run "screen" (apt-get install it if it isn't there), and run the web-app under that. You can re-attach with "screen -x" and you can detach from it with "Control-A COntrol-D". That way it won't die when you disconnect.

However, the way I would do it is to run it under Apache, so Apache starts and stops the app. It also then runs under the Apache user, which may be good or bad, but is usually good. Typically that would involve:

  • Using mod_wsgi.
  • Create a file in /etc/apache2/conf.d named after your application.

It should contain:

WSGIPythonPath /path/to/webapp/root WSGIScriptAlias /appname /path/to/webapp/root/controller.py 
  • In this case your webapp would be in the "controller.py" file. The "/appname" is the part of the URL that accesses this app, for example: http://127.0.0.1/appname
  • That webapp then needs to be a WSGI app, for example it should end with:

WSGI Example:

cfg = config() cherrypy.config.update() application = cherrypy.APplication(None, script_name = '/appname', config = cfg) 

The key thing is that you need to create an "application" object in your controller.

Once you do that, you should be able to restart Apache (/etc/init.d/apache2 restart) and then access the webapp via that URL.

5
  • Thank you very much for your detailed response. While this is just a testing and demonstration configuration now, the final deployment will also be to a cloud based virtual server (probably at Rackspace) and I was thinking of using the same setup (the server is dedicated to this single application). I've haven't enjoyed configuring Apache on the couple of occasions in the past when I've had to do it and, unlike Django, the CherryPy server seems to be intended for running production applications. Do you feel that's not appropriate? Commented Oct 18, 2011 at 10:52
  • I don't honestly know if CherryPy's default server can stand up to load well. Commented Oct 21, 2011 at 5:52
  • If this application ever gets five hits a minute, I'll be surprised. It's internal to a company planned to grow to five people, it collects narrative information so that each update will probably take a minute or two to create on the client side. It sounds like CherryPy will work for me. Commented Oct 21, 2011 at 11:54
  • Ok, but how are you going to make sure that it is up when the system is rebooted? That's the nice thing about putting it in Apache, IMHO. Commented Oct 23, 2011 at 3:19
  • Not sure, but I think one can use the cherryd script to ensure that the application starts on machine reboot. I'll be researching that this week. Commented Oct 23, 2011 at 3:21

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.