CN114398075A - Method and system for automatic deployment of go micro-service - Google Patents

Method and system for automatic deployment of go micro-service Download PDF

Info

Publication number
CN114398075A
CN114398075A CN202210069244.XA CN202210069244A CN114398075A CN 114398075 A CN114398075 A CN 114398075A CN 202210069244 A CN202210069244 A CN 202210069244A CN 114398075 A CN114398075 A CN 114398075A
Authority
CN
China
Prior art keywords
mirror image
file
container
directory
command
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210069244.XA
Other languages
Chinese (zh)
Inventor
刘德建
叶伟
李佳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujian TQ Digital Co Ltd
Original Assignee
Fujian TQ Digital Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujian TQ Digital Co Ltd filed Critical Fujian TQ Digital Co Ltd
Priority to CN202210069244.XA priority Critical patent/CN114398075A/en
Publication of CN114398075A publication Critical patent/CN114398075A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a method for automatically deploying go micro-services, which comprises the following steps: step S1, writing a batch of processing files, generating an executable binary file from the code directory, and copying the executable binary file to a packing directory and a copying configuration file packing directory; step S2, compiling files required by constructing the mirror image, entering a packaging directory, executing a container mirror image generating command, packaging container mirror image files, and uploading the container mirror image files to a mirror image warehouse; step S3, the server executes the command of pulling the mirror image warehouse, judges whether there is a new container mirror image file, if yes, the automatic arrangement command of the container mirror image file is updated and executed, otherwise, the server waits for pulling the mirror image warehouse next time; the invention can realize the deployment of the docker open source container engine and the batch processing file from the windows system one-key package to the linux server.

Description

Method and system for automatic deployment of go micro-service
Technical Field
The invention relates to the technical field of computers, in particular to a method and a system for automatic deployment of go micro-services.
Background
As the single body is increasingly used, the defects of the single body structure become more obvious, such as the items are bloated, difficult to maintain and expand, and the whole body is moved by pulling one time. In a distributed environment, the services are divided according to service boundaries, and a single application is divided into a series of services to jointly form the whole system. In the case of the micro-service architecture solving the single application pain point, new problems are derived, such as how to deploy quickly, how to arrange and manage, and the like.
Disclosure of Invention
To overcome the problems, the invention aims to provide a method for realizing deployment of key packing of batch files from windows systems to linux servers.
The invention is realized by adopting the following scheme: a method of go microservice automated deployment, comprising the steps of:
step S1, writing a batch of processing files, generating an executable binary file from the code directory, and copying the executable binary file to a packing directory and a copying configuration file packing directory;
step S2, compiling files required by constructing the mirror image, entering a packaging directory, executing a container mirror image generating command, packaging container mirror image files, and uploading the container mirror image files to a mirror image warehouse;
and step S3, the server executes a command of pulling the mirror image warehouse, judges whether a newly added container mirror image file exists, if so, updates and executes the automatic arrangement command of the container mirror image file, otherwise, waits for the next pulling of the mirror image warehouse, and therefore the purposes that the docker open source container engine and the batch processing file are packed to the linux server from the windows system through one key can be achieved.
Further, the step S1 is further specifically: and entering a code directory, creating a packaging directory app in the code directory, setting environment parameters compiled by the go micro-service, executing a go micro-service packaging command, generating an executable binary file named myprogram to the app directory, wherein the binary file is an execution file generated by a go micro-service program, and copying an app.config configuration file in the code directory to the app directory for reading configuration data of the program.
Further, the step S2 is further specifically: preparing a docker file required by constructing an image in advance, setting a Chinese time zone as content, setting codes, declaring an access port of a container and an operation command when the container is started, wherein the packaging directory app has three files, namely a docker file image file, a myprogram executable binary file and an app.config configuration file, entering the packaging directory app, executing and generating a container image command docker build, and then executing and uploading an image command docker push to a container image warehouse.
Further, the step S3 is further specifically: and writing a detection program on the server, wherein the detection program can enable the server to execute a command of pulling the mirror image warehouse every five seconds and judge whether a new container mirror image file exists in the mirror image warehouse, if so, executing a container deployment command to execute the container layout file, and performing layout configuration deployment on the container, otherwise, waiting for the next mirror image warehouse pulling.
The invention also provides a system for automatic deployment of the go micro-service, which comprises a generating module, an executing and packaging module and an operating module, wherein the generating module is used for compiling a batch of processing files, generating executable binary files from the code directory, copying the executable binary files to the packaging directory and copying the configuration file packaging directory; the execution packaging module writes files required by constructing the mirror image, enters a packaging directory, executes a container mirror image generation command, packages the container mirror image files, and uploads the container mirror image files to a mirror image warehouse; the operation module is that the server executes a command of pulling the mirror image warehouse, judges whether a newly added container mirror image file exists, if yes, updates and executes an automatic arrangement command of the container mirror image file, and if not, waits for the next pulling of the mirror image warehouse, so that a docker open source container engine and a batch processing file can be deployed from windows to the linux server in a one-key packaging mode.
Further, the generating module is further specifically: and entering a code directory, creating a packaging directory app in the code directory, setting environment parameters compiled by the go micro-service, executing a go micro-service packaging command, generating an executable binary file named myprogram to the app directory, wherein the binary file is an execution file generated by a go micro-service program, and copying an app.config configuration file in the code directory to the app directory for reading configuration data of the program.
Further, the performing and packaging module is further specifically: preparing a docker file required by constructing an image in advance, setting a Chinese time zone as content, setting codes, declaring an access port of a container and an operation command when the container is started, wherein the packaging directory app has three files, namely a docker file image file, a myprogram executable binary file and an app.config configuration file, entering the packaging directory app, executing and generating a container image command docker build, and then executing and uploading an image command docker push to a container image warehouse.
Further, the operation module further specifically includes: and writing a detection program on the server, wherein the detection program can enable the server to execute a command of pulling the mirror image warehouse every five seconds and judge whether a new container mirror image file exists in the mirror image warehouse, if so, executing a container deployment command to execute the container layout file, and performing layout configuration deployment on the container, otherwise, waiting for the next mirror image warehouse pulling.
The invention has the beneficial effects that: the invention can realize one-key compiling and deploying of the go micro-service program in cross-platform loop solution, and alleviate the pain of multi-service rapid deploying under the micro-service architecture.
Drawings
FIG. 1 is a schematic flow diagram of the process of the present invention.
Fig. 2 is a schematic block diagram of the system of the present invention.
Detailed Description
The invention is further described below with reference to the accompanying drawings.
Referring to fig. 1, a method for automated deployment of go micro-services according to the present invention includes the following steps:
step S1, writing a batch of processing files, generating an executable binary file from the code directory, and copying the executable binary file to a packing directory and a copying configuration file packing directory;
step S2, compiling files required by constructing the mirror image, entering a packaging directory, executing a container mirror image generating command, packaging container mirror image files, and uploading the container mirror image files to a mirror image warehouse;
and step S3, the server executes a command of pulling the mirror image warehouse, judges whether a newly added container mirror image file exists, if so, updates and executes the automatic arrangement command of the container mirror image file, otherwise, waits for the next pulling of the mirror image warehouse, and therefore the purposes that the docker open source container engine and the batch processing file are packed to the linux server from the windows system through one key can be achieved.
The invention is further illustrated by the following specific examples:
step 1, writing batch files, generating executable binary files from a code directory to a packing directory and copying a configuration file packing directory.
Writing the contents of the batch file as follows: entering a code directory, creating a packed directory app under the code directory, setting a 64-bit linux environment parameter set equal to amd64 set equal to goose for setting the 64-bit linux environment parameter compiled by go, executing a go packed command go built-o myprogram app, generating an executable binary file named myprogram to the app directory, wherein the binary file is an execution file generated by a go program, copying app.config under the code directory to the app directory, and using the configuration file app.config for reading configuration data by the program. The myprogram is the generated binary file name, is the myprogram in the go built-o myprogram app, and can be specified according to the project name of the myprogram. The contents are as follows:
rem entry code directory
e:
cd E:\GoPath\src\server.mico\gateway
md app
rem sets the compilation environment, builds the service
set GOARCH=amd64
set GOOS=linux
go build-o myprogram app
rem copies the configuration file to app
copy app.config app
And 2, compiling a document dockerfile for constructing the mirror image, and entering a packaging directory app to execute docker build packaging mirror image. The dockerfile is a file required for constructing the image, and the dockerfile can be prepared in advance and is a file required for constructing the image. The mirror is then constructed with docker through dockerfile.
Preparing dockerfile in advance, setting Chinese time zone, setting code, declaring access port of container and operating command when starting container. The dockerfile content is as follows:
Figure BDA0003481417450000041
Figure BDA0003481417450000051
there are 3 files under the package directory app at this time, which are dockerfile, myprogram, and app. Writing the contents of the batch file as follows: and entering a packaging directory app, executing and generating a container mirror image command docker built packaging mirror image, and then executing and uploading a mirror image command docker push to a container mirror image warehouse. The contents are as follows:
rem entry into packed directory
cd app
rem packing container mirror
docker build-t 172.24.132.232:5000/mico/gateway.
rem upload container mirror to mirror warehouse
docker push 172.24.132.232:5000/mico/gateway
And 3, executing a command of pulling the mirror image warehouse by the server every 5 seconds, judging whether a new mirror image exists, and executing a container automatic arrangement command if the new mirror image exists.
The previous step 1 is for generating an executable file for a go program, and step 2 is for packaging the container mirror to a mirror repository. At this time, the automatic packaging program is ready, only a container is needed to run on the server, in order to achieve automatic deployment, a detection program is written, and a command of pulling the mirror image warehouse is executed every five seconds: docker pull 172.24.132.232: 5000/micro/gateway, view pull information, if the mirror warehouse is updated, execute container deployment command docker-composition up-d execute container orchestration file docker-composition.yaml, docker-composition is a tool for container orchestration, can use a yaml/yml configuration file for configuration of application services, and then create and start services with a simple command. For example, the following configuration is a docker-composition.yaml with 2 services deployed:
Figure BDA0003481417450000061
version: "3" is the version of the container arrangement tool; services is a collection of container information to be deployed;
always represents that the operation strategy is always started; xxx is the mirrored warehouse address; ports are ports for container odometry snooping.
In summary, the go developer of the present invention is a local windows development environment code, and needs to release the program to the linux server. The invention realizes deployment from windows one-key packaging to a linux server based on docker and batch processing files. The method mainly comprises the following steps of compiling build.bat batch files, wherein contents comprise compiling, mirror image packaging and uploading of go codes on windows; and the other part is detection on the server, mirror warehouse updating is monitored through a program, and Docker-composition.yaml is automatically executed to complete multi-container updating deployment, wherein the Docker is an open-source application container engine.
Referring to fig. 2, the present invention further provides a system for automatic deployment of go microservices, which includes a generating module, an executing and packaging module and an operating module, wherein the generating module writes a batch of processing files, generates an executable binary file from a code directory, and copies the executable binary file to a packaging directory and a copying configuration file packaging directory; the execution packaging module writes files required by constructing the mirror image, enters a packaging directory, executes a container mirror image generation command, packages the container mirror image files, and uploads the container mirror image files to a mirror image warehouse; the operation module is that the server executes a command of pulling the mirror image warehouse, judges whether a newly added container mirror image file exists, if yes, updates and executes an automatic arrangement command of the container mirror image file, and if not, waits for the next pulling of the mirror image warehouse, so that a docker open source container engine and a batch processing file can be deployed from windows to the linux server in a one-key packaging mode.
The generation module is further specifically: and entering a code directory, creating a packaging directory app in the code directory, setting environment parameters compiled by the go micro-service, executing a go micro-service packaging command, generating an executable binary file named myprogram to the app directory, wherein the binary file is an execution file generated by a go micro-service program, and copying an app.config configuration file in the code directory to the app directory for reading configuration data of the program.
The executing and packaging module is further specifically: preparing a docker file required by constructing an image in advance, setting a Chinese time zone as content, setting codes, declaring an access port of a container and an operation command when the container is started, wherein the packaging directory app has three files, namely a docker file image file, a myprogram executable binary file and an app.config configuration file, entering the packaging directory app, executing and generating a container image command docker build, and then executing and uploading an image command docker push to a container image warehouse.
The operation module further specifically comprises: and writing a detection program on the server, wherein the detection program can enable the server to execute a command of pulling the mirror image warehouse every five seconds and judge whether a new container mirror image file exists in the mirror image warehouse, if so, executing a container deployment command to execute the container layout file, and performing layout configuration deployment on the container, otherwise, waiting for the next mirror image warehouse pulling.
The above description is only a preferred embodiment of the present invention, and all equivalent changes and modifications made in accordance with the claims of the present invention should be covered by the present invention.

Claims (8)

1. A method for automatic deployment of go micro-services is characterized by comprising the following steps:
step S1, writing a batch of processing files, generating an executable binary file from the code directory, and copying the executable binary file to a packing directory and a copying configuration file packing directory;
step S2, compiling files required by constructing the mirror image, entering a packaging directory, executing a container mirror image generating command, packaging container mirror image files, and uploading the container mirror image files to a mirror image warehouse;
and step S3, the server executes a command of pulling the mirror image warehouse, judges whether a newly added container mirror image file exists, if so, updates and executes the automatic arrangement command of the container mirror image file, otherwise, waits for the next pulling of the mirror image warehouse, and therefore the purposes that the docker open source container engine and the batch processing file are packed to the linux server from the windows system through one key can be achieved.
2. The method of claim 1, wherein the automated deployment of the go micro-services comprises: the step S1 further includes: and entering a code directory, creating a packaging directory app in the code directory, setting environment parameters compiled by the go micro-service, executing a go micro-service packaging command, generating an executable binary file named myprogram to the app directory, wherein the binary file is an execution file generated by a go micro-service program, and copying an app.config configuration file in the code directory to the app directory for reading configuration data of the program.
3. The method of claim 1, wherein the automated deployment of the go micro-services comprises: the step S2 further includes: preparing a docker file required by constructing an image in advance, setting a Chinese time zone as content, setting codes, declaring an access port of a container and an operation command when the container is started, wherein the packaging directory app has three files, namely a docker file image file, a myprogram executable binary file and an app.config configuration file, entering the packaging directory app, executing and generating a container image command docker build, and then executing and uploading an image command docker push to a container image warehouse.
4. The method of claim 1, wherein the automated deployment of the go micro-services comprises: the step S3 further includes: and writing a detection program on the server, wherein the detection program can enable the server to execute a command of pulling the mirror image warehouse every five seconds and judge whether a new container mirror image file exists in the mirror image warehouse, if so, executing a container deployment command to execute the container layout file, and performing layout configuration deployment on the container, otherwise, waiting for the next mirror image warehouse pulling.
5. A system for automated deployment of go micro-services, characterized by: the system comprises a generating module, an executing and packaging module and an operating module, wherein the generating module is used for compiling a batch of processing files, generating an executable binary file from a code directory, copying the executable binary file to a packaging directory and copying a configuration file packaging directory; the execution packaging module writes files required by constructing the mirror image, enters a packaging directory, executes a container mirror image generation command, packages the container mirror image files, and uploads the container mirror image files to a mirror image warehouse; the operation module is that the server executes a command of pulling the mirror image warehouse, judges whether a newly added container mirror image file exists, if yes, updates and executes an automatic arrangement command of the container mirror image file, and if not, waits for the next pulling of the mirror image warehouse, so that a docker open source container engine and a batch processing file can be deployed from windows to the linux server in a one-key packaging mode.
6. The system of claim 5, wherein: the generation module is further specifically: and entering a code directory, creating a packaging directory app in the code directory, setting environment parameters compiled by the go micro-service, executing a go micro-service packaging command, generating an executable binary file named myprogram to the app directory, wherein the binary file is an execution file generated by a go micro-service program, and copying an app.config configuration file in the code directory to the app directory for reading configuration data of the program.
7. The system of claim 5, wherein: the executing and packaging module is further specifically: preparing a docker file required by constructing an image in advance, setting a Chinese time zone as content, setting codes, declaring an access port of a container and an operation command when the container is started, wherein the packaging directory app has three files, namely a docker file image file, a myprogram executable binary file and an app.config configuration file, entering the packaging directory app, executing and generating a container image command docker build, and then executing and uploading an image command docker push to a container image warehouse.
8. The system of claim 5, wherein: the operation module further specifically comprises: and writing a detection program on the server, wherein the detection program can enable the server to execute a command of pulling the mirror image warehouse every five seconds and judge whether a new container mirror image file exists in the mirror image warehouse, if so, executing a container deployment command to execute the container layout file, and performing layout configuration deployment on the container, otherwise, waiting for the next mirror image warehouse pulling.
CN202210069244.XA 2022-01-21 2022-01-21 Method and system for automatic deployment of go micro-service Pending CN114398075A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210069244.XA CN114398075A (en) 2022-01-21 2022-01-21 Method and system for automatic deployment of go micro-service

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210069244.XA CN114398075A (en) 2022-01-21 2022-01-21 Method and system for automatic deployment of go micro-service

Publications (1)

Publication Number Publication Date
CN114398075A true CN114398075A (en) 2022-04-26

Family

ID=81232082

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210069244.XA Pending CN114398075A (en) 2022-01-21 2022-01-21 Method and system for automatic deployment of go micro-service

Country Status (1)

Country Link
CN (1) CN114398075A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115442206A (en) * 2022-08-25 2022-12-06 浪潮云信息技术股份公司 Method and system for GO micro-service remote deployment in cloud environment
CN116136756A (en) * 2023-04-18 2023-05-19 浪潮通用软件有限公司 Layered structure-based microservice assembly method, device, equipment and medium
CN116450153A (en) * 2023-04-26 2023-07-18 北京计算机技术及应用研究所 Rapid deployment method for containerized simulation platform

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115442206A (en) * 2022-08-25 2022-12-06 浪潮云信息技术股份公司 Method and system for GO micro-service remote deployment in cloud environment
CN116136756A (en) * 2023-04-18 2023-05-19 浪潮通用软件有限公司 Layered structure-based microservice assembly method, device, equipment and medium
CN116450153A (en) * 2023-04-26 2023-07-18 北京计算机技术及应用研究所 Rapid deployment method for containerized simulation platform
CN116450153B (en) * 2023-04-26 2023-11-24 北京计算机技术及应用研究所 Rapid deployment method for containerized simulation platform

Similar Documents

Publication Publication Date Title
CN114398075A (en) Method and system for automatic deployment of go micro-service
US11599348B2 (en) Container image building using shared resources
CN106775723B (en) Android platform-based system firmware customization method and Android device
CN108595186B (en) Multi-version software management method based on complete function on Feiteng platform
US7484223B2 (en) System and method for building a run-time image from components of a software program
US6117187A (en) Automatic generation of a software installation package
CN106843936B (en) Method for automatically deploying Web application environment
US9823915B1 (en) Software container format
US20060020937A1 (en) System and method for extraction and creation of application meta-information within a software application repository
US20060026590A1 (en) Method and apparatus for modifying software
JP7311710B2 (en) runtime container
US20110119653A1 (en) Incremental packaging
US20230125342A1 (en) Cross-platform application containerized execution
CN111930465A (en) Kubernetes-based dreams master-slave cluster deployment method and device
CN114047938B (en) Method, device, equipment and readable storage medium for constructing mirror image
JP2006163840A (en) Information processor and its method
CN115129740B (en) Method and system for updating distributed micro-service database in cloud native environment
CN116225464B (en) Rapid deployment method of platform
CN112181606B (en) Container configuration updating method, device, system, storage medium and electronic equipment
WO2007144891A1 (en) A method for the distribution of software processes to a plurality of computers
Moodie Pro Apache Ant
CN116301908B (en) Buildroot local compiling method and system based on Shenwei architecture
KR101213651B1 (en) Method for binarizing initial script on operating system, and operating method of binary script
US20230393838A1 (en) Process for automatically upgrading an operating system on a computer
Puvvala et al. NET for Java Developers Migrating to C

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination