Ubuntu16.04
这里启动一个Tornado程序
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
define("port", default=8000, help="run on the given port", type=int)
class IndexHandler(tornado.web.RequestHandler):
def get(self):
self.write("hello")
if __name__ == "__main__":
tornado.options.parse_command_line()
app = tornado.web.Application(handlers=[(r"/", IndexHandler)])
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
将启动Python的命令写入shell脚本中
#!/bin/bash
nohup python3 /home/trunk/work/test/py-test/master/14.restart_built.py &
脚本需要实现开放执行权限 sudo chmod 777 xxx.sh
sudo vim /etc/profile
添加shell脚本路径
...
/home/Desktop/selfstarting/ubuntu_start.sh
重启Ubuntu, 即可启动Tornado程序