Ubuntu startup service

Ubuntu starts Python program automatically

#1 surroundings##

Ubuntu16.04

#2 demand##

#3 Start##

#3.1 Python program###

Start a Tornado program here

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)classIndexHandler(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()

#3.2 shell script###

Write the command to start Python into the shell script

#! /bin/bash
nohup python3 /home/trunk/work/test/py-test/master/14.restart_built.py  &

The script needs to achieve open execution permissions sudo chmod 777 xxx.sh

#3.3 Configuration

sudo vim /etc/profile

Add shell script path

... /home/Desktop/selfstarting/ubuntu_start.sh

#3.4 Restart###

Restart Ubuntu to start Tornado program

Recommended Posts

Ubuntu startup service
Open SSH service under Ubuntu
Open SSH service under Ubuntu
DNS service construction under Ubuntu
Ubuntu18 restart docker service failed memo
Ubuntu19.10 open ssh service (detailed process)
How to build nfs service on ubuntu16.04
ubuntu, deepin custom program startup menu creation
Ubuntu software
How to set PostgreSQL startup on Ubuntu 16.04
windows use ubuntu to start linux service