Welcome to Deployment Recipes Part 11 – We look into some other aspect of deployment in today’s article. This article is specific to web2py my framework of choice.
Application Deployments
Arptic
- Create the application or prepare the application for all the deployment functions
For example:
- Once application is on VPS server – provide all appropriate permissions to required folders for example static and its sub folders where we allow to upload images or write files etc.
- Rename existing db see this document for details for postgres
- Create new db
- Edit controllers\default.py and make all numbers are set to 0 for index()–
- Sellable Imges
- Non sellable images
- News
- Blogs
- First – executeSetup () — Let it execute as this takes some time. Once it is done and you are able to see the front page. Disable this function
- Second – Copy news Enable install_news_linux() and once it executes and you are able to see front page without errors. Disable this function
- Third – Copy blogs Enable install_blogs_linux() and once it executes and you are able to see front page without errors. Disable this function
- Finally, Edit controllers\default.py and make all numbers are set as below for index()–
- Sellable Imges – 12
- Non sellable images -12
- News – 3
- Blogs – 3
- To display this site – Just add it to routes.py (webserver restart is required)
routers = dict(
#base router
BASE=dict(
#default_application=’Target’,
domains= {
‘www.targetsoft.co.in‘ : ‘Target’,
‘www.arptic.in’ : ‘arptic’,
}
),
)
Production code for web2py folder for routes.py
routers = dict(
#base router
BASE=dict(
#default_application=’Target’,
domains= {
‘www.targetsoft.co.in’ : ‘Target’,
‘targetsoft.co.in’ : ‘Target’,
‘www.arptic.in’ : ‘artptic’,
‘arptic.in’ : ‘arptic’,
},
#default_application = ‘Target’,
applications=[‘Target’, ‘arptic’, ‘Aavia9’],
default_fucntion = ‘index’,
),
Target = dict(
default_language = ‘en’,
languages = [‘en’],
default_function = ‘index’,
),
artpic = dict(
default_language = ‘en’,
languages = [‘en’],
default_function = ‘index’,
map_hyphen = True,
),
)
- Restart webserver and try pointing your browser to your site, it should work now.
- Once the entire setup is completed check your site and also your database to see if you can access everything and if all the data is in the system.
- Finally add smtp server and make sure it works
- Performance optimizations come for the app later
- Check usage statistics from time to time
- Check <applicationname>\errors\ folder from time to time for errors
Issue handling
- Gevent issues are complex – just comment out all the imports for gevent and the code
<class ‘gevent.exceptions.LoopExit’> This operation would block forever
- upload issue – check if all the filed values are being saved in the database if not – makesure this is done
- For email issues make sure the SMTP settings are specified properly
[Errno 111] Connection refused
- import socket in db.py for fixing this issue
global name ‘socket’ is not defined