Use Apache2 as Webserver
Warning
This section has not been updated since v.3.2. Bots in the current version may operate differently than described below.
Bots uses cherrypy webserver Out of the Box and in order to scale it, you need to run it on an Apache2 Web Server
One advantage with this is that apache2 will take care of starting the Bots Monitor so there is no need to create a daemon for the bots webserver.
Procedure
Ensure that apache2 is installed and running on the system. (try
httpd -M)The
mod_wsgipackage is needed for this set up, so install it and add the lineLoadModule wsgi_module modules/mod_wsgi.soto apachehttpd.conffile.Restart the apache server, run the command
httpd -Mand you should see thewsgi_moduleat the end.Now we need to shuffle a few directories, create a base directory called bots_app in your home folder (do not run under root)
Move the folders botssys, usersys, media and config from the bots installation directory to bots_app folder.
Do not forget to create sym links for these folders in the installation dir to this new location.
Now add the following files to the bots_app folder:
##bots.wsgi import sys import django.core.handlers.wsgi import mod_wsgi #set PYTHONPATH...not needed if bots is already on PYTHONPATH #sys.path.append('/usr/local/lib/python2.7/dist-packages') from bots import apachewebserver config = mod_wsgi.process_group apachewebserver.start(config) application = django.core.handlers.wsgi.WSGIHandler()
##apache2.conf Listen {PORT} NameVirtualHost \*:{PORT} ## Use this if you run into socket errors on linux WSGISocketPrefix /var/run/wsgi <VirtualHost \*:{PORT}> WSGIScriptAlias /{PATH TO UR HOME}/bots_app/bots.wsgi WSGIDaemonProcess config user={System User} group={System User Group} WSGIProcessGroup config ## Use this section only when enabling https for bots app SSLEngine on SSLCertificateFile /path/to/www.example.com.cert SSLCertificateKeyFile /path/to/www.example.com.key Alias /media {PATH TO UR HOME}/bots_app/media <Directory {PATH TO UR HOME}/bots_app/> Order deny,allow Allow from all </Directory> <Directory {PATH TO UR HOME}/bots_app/media> Order deny,allow Allow from all </Directory> </VirtualHost>
Add execute permission to the
bots.wsgifile and add the lineInclude {PATH TO UR HOME}/bots_app/apache2.confat the end of the apache2httpd.conffile.Restart apache server and open
http://{ip}:{port}/, you should see the bots welcome screen. If you get permission errors or images are not loading then correct permissions need to be given to bots_app and its parent directory.Once the server is running the logs will be generated in the folder
botssys/loggingasapache_webserver_config.logThe script
bots-webservershould not be used now as apache2 will automatically start up the application.Add
botsengine_path = /usr/local/bin/bots-enginein the Bots ini file.