Golang the blog daemon on Linux CentOS 6.5 server boot

Source: Internet
Author: User

There are a lot of ways to start booting under Linux , and here I use the way I write shell commands in /etc/rc.local .

Here is my actual operation as an example, many places need to crossing themselves to adjust the information Oh!

1. In the /etc/rc.local file, add the script that you want to execute.

For example, what I'm going to do now is a script that starts with the Golang project:

Ficowlogpath= "/home/ficow/autolaunchlog.txt" #launch ficow ' s blog servercd/home/ficow/ficowblog/src #进入到目录. serverautorun.sh #执行Golang项目启动脚本echo "Ficowblog server autolaunched: ' Date '" >> $ficowLogPath #启动信息记录到/home/ Ficow/autolaunchlog.txt

  

Then save the exit.

There may be problems with rc.local not being executed. If so, the permissions to modify the rc.local file are executable!

  chmod +x rc.local

2. Adjust the Golang project startup script (./serverautorun.sh)

#! /bin/bashexport Gopath=/home/ficow/gopath: ' CD. ; PWD ' echo ' Gopath: $GOPATH "Export Goroot=/home/ficow/goecho" Goroot: $GOROOT "path= $PATH: $HOME/bin:usr/local/git/bin: $GOROOT/bin: $GOPATH/bin:echo "PATH: $PATH" (Go run main.go >>/home/ficow/ficowblog/src/bloglog.txt 2>&1 &) echo "* * * Server reboot complete! ***"

  

Note: Since these scripts were executed as Su at startup, my gopath and goroot are not configured for Su,

So here I made the adjustment so that Su can know where gopath and goroot are, so that when the go run is executed, the error will not be made.

3. Permissions to modify the./serverautorun.sh file are executable:

  chmod +x./serverautorun.sh

4. Restart the server. When you connect to the past with SSH, the program is already running, and the record has been exported to the log file.

5. The following is my deployment of the program corresponding to the blog, crossing want to see?

       Click to go directly to my blog (ficow.cn)

Reference article:

Linux Add Boot Script example

Linux boot script or service

CentOS 6.5 rc.local Boot does not perform a solution to a case

Ways to let processes run in the background in Linux

Ficow Original, reproduced please specify the source: http://www.cnblogs.com/ficow/p/6681473.html

Golang the blog daemon on Linux CentOS 6.5 server boot

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.