Detailed Description
Aiming at the description content of the background technology part, in the face of frequent production requirements, the application hopes that the whole production operation can be automated, for example, program codes for logging in a production server, uploading an application program package, starting and stopping services, recording command execution conditions and the like in the production process are input into an automated deployment tool, and the production process of each service is realized by executing the program codes. Based on the method, the system and the equipment, a Goland programming language is provided, a production behavior which is repeated for many times is abstracted into modules in an initiative mode, all contents are packaged into a tool, and an executor of the production operation can quickly and accurately realize functions of batch system configuration, batch program deployment, batch operation commands and the like only by simple configuration before the production operation is executed.
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and the embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that "system", "apparatus", "unit" and/or "module" as used herein is a method for distinguishing different components, elements, parts or assemblies at different levels. However, other words may be substituted by other expressions if they accomplish the same purpose.
The term "including" and variations thereof as used herein is intended to be open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence of the functions performed by the devices, modules or units. And references to "a", "an" and "the" modifications in this disclosure are intended to be illustrative rather than limiting, as those skilled in the art will appreciate that the term "one or more" will be understood unless the context clearly indicates otherwise.
Additionally, flow charts are used herein to illustrate operations performed by systems according to embodiments of the present application. It should be understood that the preceding or following operations are not necessarily performed in the exact order in which they are performed. Rather, the steps may be processed in reverse order or simultaneously. Meanwhile, other operations may be added to the processes, or a certain step or several steps of operations may be removed from the processes.
Referring to fig. 1, a schematic structural diagram of an optional example of a project deployment system based on Golang provided by the present application is shown, and a cross-platform compiling characteristic of Golang is utilized, so that the system provided by the present application can be used in a cross-platform manner, and supports various operating systems and Central Processing Units (CPUs), thereby greatly reducing the constraint limitations of the operating system type used for project development for developers and the platform type of a server to be deployed for the project, and improving the flexibility and convenience of project development and test use thereof. In the embodiment of the application, the project deployment system based on Golang can be implemented by being supported by a server, but the application does not limit the type of the server supporting the operation of the system.
In conjunction with the above description related to the technical solution of the present application, as shown in fig. 1, the Golang-based project deployment system proposed by the present application may include: a provisioning module 110, a plurality of function encapsulation modules 120, a Golang open source library 130, and a project deployment controller 140, wherein:
the preset module 110 may include a command line Interface (Commandline Interface) module 111 and a configuration Scripts (Config Scripts) module 112. In practical application of the present application, a project developer/tester may log in a system through a client, and may input a command through the command line interface, so that the system may execute in a command manner, obtain a corresponding parameter or implement a corresponding processing, and the like.
The configuration script module 112 may be configured to configure detailed parameters of the execution command, define a deployment process of a target project (which may be any application developed according to business requirements and to be deployed to a production server, such as a gateway project, and the like, and the application is not limited to a project type), and generate a corresponding configuration file by using a scripting language (such as lua) according to the deployment process. Referring to the schematic configuration file structure shown in fig. 2, a task (task, which may be referred to as a deployment task) may be defined in a configuration file using a lua scripting language, and all instructions that need to be executed are configured and defined in a stage (step) and step (step) manner, where the configuration definition process may be implemented by using a built-in lua function, and the following example is obtained for the configuration file:
it should be understood that a configuration file may include multiple tasks, and different tasks may be configured with respective task identifiers to distinguish, for example, by task name or "demo" in the above example of the configuration file, but not limited to, that task identifiers include but are not limited to task names.
In addition, it should be noted that, in the face of different target projects, the functions and implementation processes of the target projects are different, the deployment requirements may also be different, and the deployment process information contents defined by the staff often differ, so that the configuration file contents constructed by using the script language also differ.
The function encapsulation Modules (Modules) 120 are used to implement encapsulation of core functions, and most of the functions can be implemented by calling Modules, which can be regarded as encapsulation of the gold open source Library (Library) 130 and the Golang built-in Library. As described above in relation to the technical solution of the present application, the present application may abstract the production behavior repeated multiple times into one module, that is, each function module included in the function encapsulation module 120, so that when a target project is produced, a required function module may be directly selected and called through a command, the target project is produced this time, a large number of program codes do not need to be manually written, a problem that a potential misoperation may cause is avoided, automation and reuse of production are achieved, and a technical threshold of a production operator is lowered. The number and types of the functional modules included in the functional encapsulation module 120 in the system are not limited, and the functional modules can be flexibly expanded according to scene requirements.
In some embodiments, in combination with the UML (Unified Modeling Language or standard Modeling Language) class diagram shown in fig. 3, the script engine in the function packaging module 120 packages a registration module and executes script file and string script functions, as shown in fig. 3, the functions packaged by script engine may include but are not limited to: register modules (i.e., a registry module), script engine evenstring (i.e., an execution script string), script engine evenfile (i.e., an execution script file), script engine destroy (i.e., a destroy script engine), and the like.
The credential storage module (CredentialsStore) shown in fig. 3 encapsulates a password management function, and can be used for encrypting and storing a password (i.e., an authentication credential) of a server, so that a plaintext password is prevented from being used in a configuration file, and the data storage security is improved. Based on this, the functions of the CredentialsStore module package may include, but are not limited to: confidential store (i.e., open credential store), confidential store (i.e., get server authentication credentials, the present application does not limit the type of authentication credentials, as the case may be). As shown in fig. 3, the present application may be implemented by loading a credential file, and the credential content may include but is not limited to: module extension can be performed according to deployment requirements, and details of the module extension are not described herein, for example.
Based on the function of file transfer module (FileTransfer) encapsulation of the SSH (Secure Shell) protocol, as shown in fig. 3, a client may transfer data to a server based on the SSH protocol (e.g., a file transfer scenario represented by SSHClient shown in fig. 3), or may establish a session (session) based on the SSH protocol, so as to implement data interaction between multiple parties participating in the session (e.g., a file transfer scenario represented by SSH. Thus, the file transfer module (FileTransfer) may include, but is not limited to: file transfer, transformfile (i.e., transfer local file to server), file transfer, stat (i.e., view server file information), etc.
The description of the content of the SSHClient module shown in fig. 3 may be combined, and the module may be configured based on the SSH protocol, that is, SSHConfig, and implement communication connection between the client and the server based on the SSH protocol, that is, ssh.connection, based on which the functions encapsulated by the SSHClient module may include, but are not limited to: sshccontent.connect (i.e., establish a client-to-server ssh connection), sshccontent.opensession (i.e., create a client-to-server ssh session), and sshccontent.close (i.e., close a client-to-server ssh connection). Therefore, in the communication control process between the client and the server, the corresponding codes in the SSHClient module can be reasonably called according to the deployment requirement, so that the communication control of the corresponding function is realized.
In this application, remote commands can be executed based on the SSH protocol, and for the above function encapsulation related to the SSH protocol, in addition to encapsulating the file transfer function, the function encapsulation also encapsulates a remote command execution function, such as a shell executor module in fig. 3, through which a command sent by a client can be executed, which is generally based on establishing a communication connection between the client and a server, and the client sends the command to the server based on the SSH protocol, and the function encapsulated by the module may include but is not limited to: the method comprises the following steps of ShellExecuter, executeBatch and the like, wherein the ShellExecuter, executeBatch and the like (namely, a server executes instructions), so that corresponding codes in a ShellExecuter module can be called to realize the execution according to an actual instruction execution mode in a scene of executing the instructions by the server, and the instruction execution codes do not need to be manually written.
In addition, the function encapsulation module of the system may further include a log encapsulation module Reporter, which may be used to record events (events) occurring during task execution, and the encapsulated function may include: logEvent (i.e., logging the content of a monitored event) and renderfile (i.e., presenting the logged data in a file manner, such as generating a log report file and outputting). As shown in fig. 3, for any event that is recorded, as can be recorded, but not limited to, a start time (StartDataTime), an end time (EndDataTime), an event Subject (Subject, which can be recorded in a string format), event Details (Details, which can be recorded in a string format), and the like, flexible configuration may be performed according to actual requirements, including but not limited to a functional method encapsulated by the internal module abstracted as shown in fig. 3.
Because the automatic deployment of the target project is realized by using a Golang cross-platform compiling language, the target project adopts a lua script language to construct the configuration file, but the lua code in the configuration file cannot directly call the Golang code in each function module of the system, the Golang code of the called function module is registered as the lua extension according to go-lua Birdge (a conversion module between the Golang compiling language and the lua script language and is marked as a go-lua code conversion module), so that the called Golang code can be registered in the lua instance in the following process, including the reliable completion of the automatic deployment, and the realization process is not detailed in the application.
The Golang open source library 130 is an implementation of a system underlying function, and is generally a third-party Golang open source library, including but not limited to ssh-client (ssh client), scp (secure copy, transport command), go-lua (Golang call lua script), cobra (go language library), and the like shown in fig. 1, and can be flexibly configured and extended according to actual requirements.
As shown in fig. 1, the function encapsulation module 120 may further include a Script interpreter (Script interpreter)/compiler, which is used to implement compiling the function codes of the function encapsulation modules to construct the automation deployment tool provided by the present application; after the deployment process of each deployment task of the target project is configured, script compiling may be performed based on the deployment process information obtained thereby, so as to obtain a configuration file and the like for the target project.
The project deployment controller 140 may be a controller of a computer device, such as a CPU, of the system, and may execute the Golang-based project deployment method provided in the present application, and the implementation process may refer to the description of the corresponding part of the above and below embodiments, which are not described in detail herein.
It should be understood that, as shown in fig. 1, the bottom layer of the system may further include a Golang code executor (Golang Runtime) which, when compiled by the compiler, packages the invoked Golang code into an executable file suitable for the target platform (i.e. an application platform supported by the production server that needs to deploy the target item), and sends the executable file to the production server for running, thereby completing the commissioning operation of the target item. Because Golang supports various operating systems such as windows, linux, macos and the like, an operator does not need to write program codes of a target item aiming at the operating system installed on equipment independently, and the target item can be used in a cross-platform mode.
In addition, the modules described in the embodiments of the present disclosure may be implemented by software, or may be implemented by hardware. Wherein the name of a module does not in some cases constitute a limitation on the module itself. And the functions described herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems on a chip (SOCs), complex Programmable Logic Devices (CPLDs), and the like.
The system architecture described in conjunction with the above embodiments, as shown in fig. 4, is a flowchart of an optional example of a Golang-based project deployment method proposed in the present application, which may be executed by a server supporting operation of the Golang-based project deployment system, as shown in fig. 4, and the method may include:
step S41, responding to a deployment request aiming at a target project, and acquiring a configuration file of the target project; the configuration file comprises deployment flow information of at least one deployment task defined aiming at the target project;
in combination with the above description of the configuration file in the embodiment, in order to adapt to the deployment modes of different projects (such as application programs, etc.), the present application adopts lua scripting language to construct the configuration file, so as to increase the flexibility of configuration to the maximum extent, and a system operator can customize a deployment process for a target project, that is, define at least one deployment task related to the target project, configure instructions to be executed by the entire deployment process in the modes of stage and step, and obtain corresponding deployment process information.
For some functions included in the configuration file, it is simpler to use a script language than to use a golang compilation language definition, for example, a task function, a definition function of a deployment task may be:
as can be analyzed, such functions may be referred to as built-in lua functions, which may include, but are not limited to, the lua function name being, in order: task (i.e., define task, i.e., define deployment task), stage (i.e., define stage), step (i.e., define step), runTask (i.e., execute task), runAllTask (i.e., execute all tasks). The codes included in these built-in lua functions may be determined by referring to the deployment task definition codes of the task function above, which is not described in detail herein.
In the process of constructing the configuration file, the script configuration module in the system may include various functions related to the project deployment process, and the operator fills in a task identifier, a configuration item and the like suitable for the target project according to the deployment requirement of the target project, calls the corresponding function, generates a lua function code corresponding to the deployment task required by the target project, completes the definition of each deployment task, and obtains corresponding deployment process information.
It should be understood that after an operator logs in the system through a client, the system generally loads the corresponding at least one dependent item according to the obtained configuration file of the target item, that is, according to the configuration file go.
The dependency terms loaded in require above can be expressed as follows: realizing the parameter analysis of the command line; various encryption algorithms and protocols are realized, including ssh protocol; realizing a file transfer protocol based on the ssh protocol; lua script engine implemented with golang. And subsequently processing the content contained in the obtained configuration file until the production operation of the target item is completed, wherein the processing can be realized according to the requirements of the loaded dependent items.
After the dependent item loading is completed, the common libraries can be packaged, such as the above listed golang open source library, so that information in the corresponding libraries can be called later, and the production operation requirements can be met.
Step S42, calling a script engine module in the function packaging module, and creating a script engine aiming at the configuration file;
as described in the above related description of the system embodiment, the deployment process (i.e., the commissioning operation behavior) of the application project is abstracted into function packaging modules, and each process step is packaged into a corresponding function packaging module, so that the function packaging module of the application may be constructed based on different contents of the project deployment process, and the function implementation methods packaged by different function packaging modules are different, and the function implementation method packaged by the function packaging module may refer to but is not limited to the description of the corresponding part of the system embodiment, which is not described in detail herein.
As described above in relation to the functions encapsulated by script engine module script engine, script engine suitable for the configuration file of the target project can be created accordingly, and the script engine includes modules such as registers modules, evalString, evalscale and Destroy, each module includes a code for implementing its own function, and the content of the code is not described in detail in this application.
Step S43, converting the called Golang code of the function packaging module into a lua extension through a registration module packaged by the script engine, and then registering the Lua extension to a lua instance so as to enable the configuration file to call a corresponding Golang function through the lua function;
since the lua code in the configuration file cannot directly call the golang code, the present application may use the golang code to define the lua extension, i.e., register the golang code as the lua extension for subsequent registration into the lua instance. The definition of the lua extension process is illustrated by taking the sshxecute module executing instructions at the server as an example:
the implementation process of the lua extension of the functional encapsulation module constructed by other golang codes is similar, and the detailed description is omitted in the present application. Regarding the implementation process of registering the gold code as the lua extension, a go-lua border module in the function encapsulation module may be called to implement the implementation process, and the subsequent lua function registration instance implementation process may be implemented by using a registration module encapsulated by a script engine, and still take the instance registration of the sshExecute function implementation method as an example for description, the registration code of the lua instance may include:
in the embodiment of the present application, a deployment procedure that needs to be implemented by calling a golang function using a lua code in a configuration file may be as shown in the following table:
TABLE 1
| lua function name | golang function name | Action |
| sshExecute | lsshExecute | Executing instructions at a server |
| sshEecuteBatch | lsshEecuteBatch | Performing multi-line pointing at a serverOrder to |
| fileTransformPayload | lfileTransformPayload | Transferring byte content to a server |
| fileTransformFile | lfileTransformFile | Transmitting local files to a server |
| fileStat | lfileStat | Viewing server file information |
| getCredentials | lgetCredentials | Obtaining server authentication credentials |
Regarding the implementation process of other lua functions in table 1, reference may be made to the implementation process of the sshxecute registered lua instance described above, and details of this application are not given by way of example.
S44, executing a corresponding deployment task according to the deployment flow information, and deploying the target project to a target server for operation;
in practical application, for the entire automated deployment method, the automated deployment method can be implemented by defining a main function, and the main function main.
The deployment task is named as "deployment: gateway", and the execution process of the deployment task is that the "ez deployment: gateway" is executed in the easy box. In the actual execution process, a parameter of the deployment task, which is "deployment: gateway", may be determined from the command line, and the created script engine obtains a configuration item corresponding to the deployment task, so as to execute the deployment task according to the configuration item, which is not described in detail in this application. It is understood that the implementation process of other deployment tasks included in the configuration file is similar, and the detailed description of the example is not given in this application.
The implementation process of deploying the target project to multiple servers by executing the deployment task defined by the configuration file can refer to a gateway-server deployment task implementation process represented by the following code:
step S45, destroy the created script engine.
After each signature task contained in the configuration file is executed, the created script engine can be destroyed through a Destroy module packaged by the script engine, so that the memory space occupied by the script engine is recycled.
In summary, in the embodiment of the present application, under a condition that a target project needs to be deployed, a configuration file of the target project, that is, deployment process information of at least one deployment task defined for the target project, may be obtained, so as to improve configuration flexibility, and facilitate a user to develop a function and an extension function that meet the target project, and the present application may construct a corresponding function encapsulation module based on different contents of a project deployment process, and encapsulate the function encapsulation module into an automatic deployment tool, so that a script engine module in the function encapsulation module may be directly invoked, a script engine for creating the configuration file for the target project, and a registration module encapsulated by the script engine registers a gold code of the invoked function encapsulation module as a lua extension and then registers the lua extension to a lua instance, so that the configuration file may invoke a corresponding gold function through the lua function, execute the corresponding deployment task according to the deployment process information, run the target project to a target server, reduce cost of cross-platform development, and do not need to care about a command writing manner, thereby avoiding various operations generated by a manual operation command, resulting in turn, reducing production time and labor cost, and improving production efficiency and labor reliability.
Referring to fig. 5, a schematic flow chart of yet another optional example of the Golang-based item deployment method proposed in the present application may be described as an optional detailed implementation procedure of the Golang-based item deployment method described in the above embodiment, but is not limited to the detailed implementation method described in the present embodiment, and as shown in fig. 5, the detailed implementation method may include:
step S51, responding to the deployment request aiming at the target project, and acquiring a configuration file of the target project;
step S52, a script engine module in the function packaging module is called, and a script engine aiming at the configuration file is established;
step S53, registering the called Golang code of the function packaging module as lua extension through a registration module packaged by the script engine and then registering the Lua extension to the lua example so as to enable the configuration file to call the corresponding Golang function through the lua function;
regarding the implementation process of step S51 to step S53, reference may be made to the description of the corresponding parts in the above embodiments, which is not described herein again.
It should be understood that, in an actual application of the present application, in a process of implementing target project deployment by using a golang automation deployment tool, a dependent item required by a target project is usually loaded, for example, after a deployment command sensed by a response command line interface is responded, a project identifier of the target project is determined, a dependent item associated with the project identifier is loaded, and the dependent item is linked to the target project, so that, after the dependency is introduced by the automation deployment tool, a function encapsulation module for deploying the target project to a target server may be constructed according to the loaded dependent item, for example, a common library in a project deployment application is encapsulated, so that the common library can be directly called when the target project deployment tool can be used later, and convenience and efficiency of subsequent project deployment are improved.
Step S54, obtaining a first task identifier in a command line mode;
as described above with respect to the configuration file, one configuration file of the target project may include multiple deployment task tasks, and configure corresponding task identifiers to distinguish different tasks, where the task identifier may be a task name, such as "demo" in the above configuration file example. Therefore, for any deployment task needing to be executed, the method and the device can execute the automatic deployment tool in a command line mode through a command line interface module in the preset module, trigger the configuration script module to configure detailed parameters of the execution command, and obtain a first task identifier of the deployment task needing to be executed. But is not limited to such an implementation.
Step S55, acquiring a configuration item corresponding to the first task identifier from the deployment process information through the script engine;
after obtaining the first task identifier of the deployment task to be executed, the script engine may parse the configuration file of the target project, and query, from the deployment process information of the target project, the configuration item corresponding to the first task identifier, for example, different execution step contents of different task stages defined by the deployment task having the first task identifier.
Still by taking the content of the configuration file of the deployment task with the task identifier "demo" as an example for explanation, after the task identifier "demo" is obtained, the configuration file may be analyzed, and from the deployment process information corresponding to the deployment task with the name "demo", the content in the parenthesis after "demo", that is, all the configuration items corresponding to "demo" are determined. It is understood that the configuration items corresponding to different deployment tasks are often different, and the embodiment of the present application is not described in detail herein.
In some embodiments presented herein, the content of each task may be stored in one table; the contents of all the tasks defined for the same project can be stored in one table, and the corresponding relationship between each task and the contents of the configuration item can be reserved. Based on this, in the present application, a correspondence table (e.g., table) may be used to store the configuration items of the deployment task with the same task identifier, so that the configuration items can be sequentially executed according to the correspondence table, and thus, the script engine may query the correspondence table to determine the configuration items corresponding to the first task identifier, that is, determine the configuration items corresponding to the deployment task, but is not limited to this configuration item obtaining manner.
Step S56, executing a deployment task with a first task identifier according to the obtained configuration item;
in the embodiment of the application, after the configuration file of the target project is analyzed, each deployment task defined for the target project and the configuration item corresponding to each deployment task may be determined, and the deployment task corresponding to the obtained first task identifier may be executed accordingly, for example, the stages included in the deployment task are executed in sequence, and the implementation process is not described in detail.
In still other embodiments, if the configuration file of the target project is parsed according to the method described above, and the first task identifier is not obtained in a command line manner, which indicates that the configuration file does not include the deployment task with the first task identifier, all the deployment tasks predefined by the target project may be directly executed, and therefore, in a case where the first task identifier is not obtained, all the deployment tasks included in the configuration file may be executed according to the deployment flow information of the target project.
Step S57, calling a predefined log function;
step S58, executing a log function, recording the execution process of the deployment task, and obtaining corresponding log data;
step S59, generating a task execution report in a preset format using the log data.
In the embodiment of the application, in the process of executing the deployment task of the configuration file, a Reporter module in the function encapsulation module may be called, the process of executing the deployment task is recorded in a log mode, the obtained log data is generated into a task execution report in a preset format (such as html), and the implementation process and the content of the task execution report are not limited in the application.
Optionally, the generated task execution report may be stored in association with a configuration file of the target project for subsequent viewing. For example, if the task execution report of the target item is triggered to be checked, and the task execution report is sent to the corresponding terminal for output, as shown in fig. 6, a task execution report diagram may record task start time, end time, running result, and the like, as appropriate. In this way, a developer can determine whether the execution process of each deployment task defined for a target project is normal by viewing the content of a task execution report, as can be seen from the content of the task execution report shown in fig. 6, this example executes 3 stages (i.e., the content corresponding to sequence numbers 1, 2, and 3 in fig. 6), each stage can expand to view the specific execution step in the stage execution process (e.g., the execution steps corresponding to sequence numbers 1.1, 1.2, 1.3, 1.4, and 1.5 in fig. 6), and record the log data executed by each step in detail, can trigger the "detail" prompt button corresponding to the task execution step, output the log data content generated by the execution process corresponding to the deployment task, e.g., fig. 6 clicks the "detail" prompt button corresponding to the stage of sequence number 1, outputs the log data corresponding to 5 steps included in the stage, can click the "x" button displayed at the upper right corner of the log data, and close the display of the log data.
It can be understood that, for the content of the task generation report, the report recording rule of the task generation report can be flexibly adjusted according to the application requirements of error checking, record keeping and the like, so that corresponding log data can be automatically extracted and recorded according to the adjusted report recording rule, and thus the task generation report conforming to the report recording rule is generated, so that the detailed content of the task generation report can be queried or analyzed subsequently, and the subsequent processing of error checking, record keeping and the like can be realized.
In addition, it should be noted that the above-mentioned embodiments correspond to flowcharts and block diagrams included in the accompanying drawings, which illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s).
It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
That is, for the above method embodiments, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. It should be understood that the various steps recited in method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
Referring to fig. 7, a schematic hardware structure diagram of an optional example of a computer device suitable for the method for Golang-based project deployment proposed in the present application is shown, where the computer device may be a terminal device or a server, and the terminal device in the embodiment of the present application may include, but is not limited to: a smart phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle-mounted terminal (e.g., a car navigation terminal), a smart transportation device, a smart medical device, a virtual reality device, and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The computer device shown in fig. 7 is only an example and should not bring any limitation to the function and scope of use of the embodiments of the present disclosure.
As shown in fig. 7, the computer device may include aprocessing device 71 and astorage device 72, wherein thestorage device 72 may be used for storing a program implementing the Golang-based item deployment method proposed in the present application; theprocessing device 72 may read and load the program, and the implementation process of the project deployment method based on Golang provided by the present application is not described herein again.
In some embodiments, theprocessing device 71 may include, but is not limited to, a central processing unit, a graphics processing unit, and the like, and it can be understood by combining the analysis, that theprocessing device 71 may include a project deployment controller of a project deployment system based on Golang, and the deployment task of the target project is implemented by controlling each component module/module in the system, and the implementation process may refer to the description of the corresponding part in the above embodiments, which is not described herein again. It can be seen that the computer device proposed in the present application may include the Golang-based project deployment system proposed in the above embodiments, and the present embodiment is not detailed here regarding the constituent structure of the system.
In still other embodiments of the present application, thestorage device 72 may include, but is not limited to: various types of memories such as a Read Only Memory (ROM), a Random Access Memory (RAM) and the like, so that, in practical applications, theprocessing device 71 may execute various appropriate actions and processes according to a program in the Read Only Memory (ROM) or a program loaded into the Random Access Memory (RAM) from a storage device such as a magnetic tape, a hard disk and the like of the storage device, thereby implementing the Golang-based item deployment method proposed in the present application. In the RAM, various other programs and data required for the operation of the computer apparatus may also be stored. Theprocessing device 71, the ROM, and the RAM are connected to each other by a bus. An input/output (I/O) interface is also connected to the bus to enable data interaction between internal components of the computer device and to meet data transmission requirements of the computer device and external devices.
It is understood that, in case of the computer device being a terminal device, the computer device may further include at least one input component such as a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc., at least one output component such as a Liquid Crystal Display (LCD), a speaker, a vibrator, etc., capable of being connected to an I/O interface of the computer device, and at least one communication device capable of being connected to a wireless/wired network, the communication device may allow the computer device to communicate with other devices through a wired network and/or a wireless network, so as to meet data transmission requirements between different devices. It should be noted that the structure of the computer device shown in fig. 7 does not limit the hardware composition thereof, and does not require to implement or have all the devices shown, and may be implemented alternatively or have more or less devices according to the actual needs, which is not an example in this application.
In combination with the above description related to the technical solution of the present application, according to one or more embodiments of the present disclosure, an example of the method shown in fig. 4 is provided, where the method for Golang-based item deployment includes:
responding to a deployment request aiming at a target project, and acquiring a configuration file of the target project; the configuration file comprises deployment flow information of at least one deployment task defined aiming at the target project;
calling a script engine module in the functional packaging module, and creating a script engine aiming at the configuration file; the function packaging module is constructed based on different contents of the project deployment process, and the function implementation methods packaged by the different function packaging modules are different;
converting the called Golang code of the function packaging module into a lua extension code and then registering the Lua extension code to a lua example through a registration module packaged by the script engine so that the configuration file can call a corresponding Golang function through the lua function;
executing the corresponding deployment task according to the deployment flow information, and deploying the target project to a target server for operation;
and destroying the script engine.
In accordance with one or more embodiments of the present disclosure, in a method for Golang-based item deployment provided by the method example shown in fig. 5, according to the deployment flow information, the implementation process of executing the corresponding deployment task may include:
obtaining a first task identifier in a command line manner;
acquiring a configuration item corresponding to the first task identifier from the deployment process information through the script engine;
executing the deployment task with the first task identification according to the obtained configuration item.
According to one or more embodiments of the present disclosure, in a method for Golang-based item deployment provided by the method example shown in fig. 4, according to the deployment flow information, the implementation process of executing the corresponding deployment task may further include:
not obtaining the first task identification in a command line manner;
and executing all the deployment tasks contained in the configuration file according to the deployment flow information.
In accordance with one or more embodiments of the present disclosure, a method for Golang-based item deployment, as provided by the method example shown in fig. 4, may further include:
storing each configuration item of the deployment task with the same task identifier in a corresponding relation table mode so as to enable each configuration item to be sequentially executed according to the corresponding relation table;
based on this, in the process of executing the Golang-based item deployment method, the step of obtaining the configuration item corresponding to the first task identifier may include:
and querying the corresponding relation table, and determining each configuration item corresponding to the first task identifier.
In accordance with one or more embodiments of the present disclosure, a method for project deployment based on Golang, as provided by the method example shown in fig. 5, during the executing of the corresponding deployment task, may further include:
calling a predefined log function;
executing the log function, and recording the execution process of the deployment task to obtain corresponding log data;
and generating a task execution report in a preset format by using the log data.
In accordance with one or more embodiments of the present disclosure, a method for Golang-based item deployment, provided by the method example shown in fig. 4, may further include:
responding to a deployment command sensed by a command line interface, and determining a project identifier of a target project;
loading a dependent item associated with the item identification, and linking the dependent item to the target item;
and constructing a function packaging module for deploying the target project to a target server according to the loaded dependent item.
In accordance with one or more embodiments of the present disclosure, a Golang-based project deployment system, as provided by the system example shown in fig. 1, may include: preset module, a plurality of function encapsulation module, gold open source storehouse and project deployment controller, wherein:
the preset module comprises a command line interface and a configuration script module, and the configuration script module is used for configuring and executing parameters of the command sensed by the command line interface and acquiring a configuration file of a target project; the configuration file comprises deployment flow information of at least one deployment task defined aiming at the target project;
the plurality of functional packaging modules comprise a script engine module, a file transmission module and a go-lua code conversion module, wherein:
the script engine module is used for creating a script engine aiming at the configuration file;
the file transmission module is used for realizing data transmission between the server and the client;
the go-lua code conversion module is used for converting the Golang code of the functional packaging module into the lua extension code, so that the registration module packaged by the script engine can register the converted lua extension code to the lua instance;
the project deployment controller is used for realizing the project deployment method based on Golang.
In accordance with one or more embodiments of the present disclosure, in the Golang-based project deployment system as exemplarily provided in fig. 1, the plurality of functional packaging modules further includes: the system comprises a certificate storage module and/or a log packaging module;
the certificate storage module is used for encrypting and storing the authentication certificates of the servers;
the log encapsulation module is used for executing a predefined log function, recording the execution process of the deployment task, and generating a task execution report in a preset format by using the obtained corresponding log data.
In accordance with one or more embodiments of the present disclosure, in the Golang-based project deployment system as provided in the example of fig. 1, may further include:
the Golay code executor is positioned at the bottom layer of the Golay-based project deployment system and is used for accessing different application platforms and deploying the target project to a target server on any one of the application platforms to run.
The embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored, and the computer program is loaded and executed by a processor to implement each step of the above-mentioned Golang-based item deployment method, and a specific implementation process may refer to descriptions of corresponding parts in the above-mentioned embodiment, which is not described in detail in this embodiment.
The computer readable medium described above in this disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
Finally, it is noted that although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.
While several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.