Deploy Web App, need to buy a domain name, I recommendhttp://www.namecheap.com/, pay by credit card or PayPal, 10 knives a year.
If you need a VPS, buy linode.com, it home new 10 per month of the host, the performance is excellent, if you choose the room in Tokyo, from the mainland to visit quickly, with overseas host does not need to record, this is the biggest selling point.
The Tornado Code of the website is running and the website can be accessed. Sometimes the site crashes for a variety of reasons, such as being attacked, code bugs, traffic too large, and so on.
an automatic monitoring script is required. This script monitors the site's tornado process, detects the process every few seconds, and restarts the process if the discovery process is gone. With it, you don't have to wake up in the middle of the night to restart the site.
zuijiacanting.com Automatic monitoring scripts like this, moniter_zjct.py
--------------------------------
#!/usr/bin/env python
#!-*-coding:utf-8-*-
Import OS
Import Time
Import SYS
class Monitorzjct:
def run (self):
While True:
Time.sleep (5)
Try:
ret = Os.popen (' ps axu|grep myweb_server.py|grep-v grep|grep python '). ReadLines ()
if Len (ret) = = 0:
Os.system ("cd/home/xxxx/yyy/bbb/; sudo./ggg/myweb_server.py ")
except:
print "Error", Sys.exc_info () [1]
if __name__ = = "__main__":
mz = monitorzjct ()
Mz.run ()
--------------------------------
This PY code detects the existence of the myweb_server.py process every 5 seconds and restarts the process if it does not exist.
This process needs to boot automatically, as follows:
1. Create the/etc/init.d/monitor_zjct file with the following content:
--------------------------------
#!/bin/bash
#cp This file to/etc/init.d/
exe= "/home/xxx/monitor_zjct.py"
Pidfile=/var/run/monior_zjct.pid
D_start () {
Start-stop-daemon--start--quiet--background--m--pidfile $PIDFILE--exec $EXE
}
D_stop () {
Start-stop-daemon--stop--quiet--pidfile $PIDFILE
RM-RF $PIDFILE
}
Case $ in
start)
D_start
;;
stop)
D_stop
;;
restart)
D_stop
Sleep 1
D_start
;;
*)
echo "Usage: $NAME {start|stop|restart}"
Exit 1
;;
Esac
Exit 0
--------------------------------
This script launches monitor_zjct.py in a daemon manner.
2. In/etc/rc.local, add a line statement "/etc/init.d/monitor_zjct start".
3. Each boot will automatically start monitor_zjct.py, it starts, will check the process, found that the Tornado program is not running, so start the Tornado program, the site began to run.
To close the Tornado program, you need to switch off the monitor_zjct.py, or it will find that the tornado process is no longer, the new tornado process is started.
If you want to update the code, after each update of the code, to kill the tornado process, after 5 seconds, monitor_zjct.py will start the tornado process again, this time the new code is running.
The automatic monitoring of boot starts mostly similar to this, much the same.