Compilation method and compilation system
By using container technology on the server to provide multiple compilation environments, the problems of low compilation efficiency and poor synchronization caused by front-end developers' need to install multiple build environments are solved, and a more efficient compilation and a more consistent collaborative development environment is achieved.
Patent Information
- Application Number
- CN201910441480.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-05-24
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2039-05-24
AI Technical Summary
Front-end developers need to install multiple build environments in the terminal, resulting in low compilation efficiency and poor synchronization, and it is difficult to ensure project consistency when multiple people develop together.
By using container technology on the server, providing multiple compilation environment images, the client can select the appropriate image to start the container according to the configuration file and execute compilation instructions in the container through long connections.
It effectively overcomes the problem of limited terminal processing capabilities, improves the consistency of collaborative development projects, and avoids the hidden danger of inconsistent development versions.
Smart Images

Figure CN111984261B_ABST
Abstract
Description
Background Art
[0002] At present, the types of front-end (generally referring to web, app, electron and other interfaces) projects have become very diverse, including HTML5, React, Vue, AngularJS, etc., but each technology needs to be compiled into a target project before it can run. This leads to the need for front-end developers to install multiple build environments in the terminal.
[0003] Currently, developers can only use local builds to deploy different environments for each development environment. However, when these environments are deployed on the same terminal, conflicts often occur. For example, one project depends on Python version 2.x, but another project depends on Python version 3.0, or the dependent operating system environment is inconsistent with the terminal. Although there are some conflict resolution solutions for specific technology stacks (such as nvm under node, using virtual machines, etc.), the operation is not convenient and relies on the local terminal.
[0004] First, due to the different performance of local terminals, if the terminal performance is low or fails, the development efficiency will be very low. Secondly, compilation is a high CPU consumption task. Once the compilation work starts, the CPU resources of the entire terminal will be fully occupied, and developers sometimes have to enter the "waiting in place" state. Third, for compilation environments that rely on different operating systems, they can only be carried out in the form of virtual machines, which have low performance and occupy additional resources. Fourth, the compiled front-end project appears directly in the form of local files, which is not conducive to team sharing and previewing. For projects developed by multiple people, it is possible that the versions of some modules are different due to the different installation time of the dependencies on the two terminals. Although most of the time this change will not affect the operation of the project, it will cause the final generated output to be different, which will bury hidden dangers.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0006] The purpose of the present disclosure is to provide a compilation method and a compilation device, which are used to overcome the problems of low compilation efficiency and poor synchronization caused by the installation of multiple compilation environments in a terminal due to limitations and defects of related technologies, at least to a certain extent.
[0007] According to a first aspect of an embodiment of the present disclosure, a compiling method is provided, including:
[0008] Respond to the preset file upload instruction of the client to receive the file to be compiled and the configuration file;
[0009] Responding to the persistent connection establishment request of the client, establishing a persistent connection with the client;
[0010] Selecting a compilation environment image from multiple compilation environment images according to the configuration file, starting a container according to the compilation environment image, and docking a control port of the container to the persistent connection;
[0011] In response to a compile instruction sent by the client through the persistent connection, executing the compile instruction on the file to be compiled within the container;
[0012] In response to a preset compilation end instruction of the client, the long connection is disconnected and the container is recycled.
[0013] In an exemplary embodiment of the present disclosure, selecting a compilation environment image from multiple compilation environment images according to the configuration file includes:
[0014] Determine the project identifier of the file to be compiled according to the configuration file;
[0015] When a corresponding compilation environment image exists for the project identifier, directly selecting the corresponding environment image;
[0016] Otherwise, select the specified compilation environment image recorded in the configuration file;
[0017] When the configuration file does not record a specified compilation environment image, a default compilation environment image is selected.
[0018] In an exemplary embodiment of the present disclosure, receiving the to-be-compiled file and the configuration file in response to a preset file upload instruction of the client includes determining a storage directory for the to-be-compiled file according to the configuration file, and starting the container according to the compilation environment image includes specifying a shared directory between the container and the host as the storage directory.
[0019] In an exemplary embodiment of the present disclosure, starting a container according to the compilation environment image includes:
[0020] The container access port is determined and exposed according to the configuration file.
[0021] In an exemplary embodiment of the present disclosure, executing the compilation instruction on the to-be-compiled file within the container includes:
[0022] The execution result of the compilation instruction is fed back to the client through the long connection.
[0023] According to one aspect of the present disclosure, a compilation system is provided, including:
[0024] The server is configured to execute the following instructions:
[0025] Respond to the preset file upload instruction of the client to receive the file to be compiled and the configuration file;
[0026] Responding to the persistent connection establishment request of the client, establishing a persistent connection with the client;
[0027] Selecting a compilation environment image from multiple compilation environment images according to the configuration file, starting a container according to the compilation environment image, and docking a control port of the container to the persistent connection;
[0028] In response to a compile instruction sent by the client through the persistent connection, executing the compile instruction on the file to be compiled within the container;
[0029] In response to a preset compilation end instruction of the client, disconnect the long connection and recycle the container;
[0030] A plurality of clients are coupled to the server, wherein each of the clients is configured to execute the following instructions:
[0031] Responding to a preset file acquisition instruction, locally acquiring the file to be compiled and the configuration file;
[0032] After sending the preset file upload instruction to the server, the file to be compiled and the configuration file are transmitted;
[0033] After the file is successfully transferred, the persistent connection establishment request is sent to the server to establish the persistent connection with the server;
[0034] Sending the compile instruction formed according to the user operation to the server through the long connection;
[0035] The preset compile end instruction is sent in response to the preset operation of the user.
[0036] In an exemplary embodiment of the present disclosure, the configuration file includes a project identifier of the file to be compiled, and the server is configured as follows:
[0037] Determine the project identifier of the file to be compiled according to the configuration file;
[0038] When a corresponding compilation environment image exists for the project identifier, directly selecting the corresponding environment image;
[0039] Otherwise, select the specified compilation environment image recorded in the configuration file;
[0040] When the configuration file does not record a specified compilation environment image, a default compilation environment image is selected.
[0041] In an exemplary embodiment of the present disclosure, the client determines whether there is a configuration file corresponding to the file to be compiled when responding to the preset startup command, and creates the configuration file if it does not exist.
[0042] In an exemplary embodiment of the present disclosure, it includes:
[0043] A file receiving module, configured to receive files to be compiled and configuration files in response to a preset file upload instruction of a client;
[0044] A connection management module, configured to establish a persistent connection with the client in response to a persistent connection establishment request from the client; and disconnect the persistent connection and recycle the container in response to a preset compilation end instruction from the client;
[0045] A container startup module, configured to select a compilation environment image from multiple compilation environment images according to the configuration file, start a container according to the compilation environment image, and connect the control port of the container to the long connection;
[0046] The file compilation module is configured to respond to the compilation instruction sent by the client through the long connection and execute the compilation instruction on the file to be compiled within the container.
[0047] According to one aspect of the present disclosure, there is provided an electronic device, including:
[0048] Memory; and
[0049] A processor coupled to the memory, wherein the processor is configured to execute any one of the above-mentioned compilation methods based on instructions stored in the memory.
[0050] According to one aspect of the present disclosure, a computer-readable storage medium is provided, on which a program is stored, and when the program is executed by a processor, the compiling method as described in any one of the above items is implemented.
[0051] The compilation method and compilation system provided by the embodiments of the present disclosure can effectively overcome the problem of limited terminal processing capacity due to the large variety of compilation environments and the large amount of resources occupied by compilation tasks by providing multiple compilation environments for multiple terminals through the use of containers located on the server; in addition, since the compilation records are saved on the server, the consistency of collaboratively developed projects can be improved and the problem of inconsistency in various development versions can be avoided.
[0052] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0054] Figure 1 is a flowchart of a compiling method 100 in an exemplary embodiment of the present disclosure.
[0055] Figure 2 It is a sub-flowchart of step S106 of the compiling method in the exemplary embodiment of the present disclosure.
[0056] Figure 3 is a schematic diagram of a compiling system 300 in an exemplary embodiment of the present disclosure.
[0057] Figure 4A and Figure 4B They are respectively the workflow diagrams of the client and the server in the compilation system 300 in one embodiment.
[0058] Figure 5 is a block diagram of a compiling device in an exemplary embodiment of the present disclosure.
[0059] Figure 6 is a block diagram of an electronic device in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0060] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0061] In addition, the accompanying drawings are only schematic diagrams of the present disclosure, and the same reference numerals in the drawings represent the same or similar parts, so their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities, which do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0062] The exemplary embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
[0063] Figure 1 The flowchart of the compiling method in the exemplary embodiment of the present disclosure is schematically shown. Figure 1 , the compilation method 100 may include:
[0064] Step S102, responding to the preset file upload instruction of the client to receive the file to be compiled and the configuration file;
[0065] Step S104, establishing a persistent connection with the client in response to the persistent connection establishment request of the client;
[0066] Step S106, selecting a compilation environment image from multiple compilation environment images according to the configuration file, starting a container according to the compilation environment image, and connecting the control port of the container to the long connection;
[0067] Step S108, responding to the compile instruction sent by the client through the persistent connection, executing the compile instruction on the file to be compiled within the container;
[0068] Step S110, disconnecting the long connection and recycling the container in response to the preset compilation end instruction of the client.
[0069] The compilation method and compilation system provided by the embodiments of the present disclosure can effectively overcome the problem of limited terminal processing capacity due to the large variety of compilation environments and the large amount of resources occupied by compilation tasks by providing multiple compilation environments for multiple terminals through the use of containers located on the server; in addition, since the compilation records are saved on the server, the consistency of collaboratively developed projects can be improved and the problem of inconsistency in various development versions can be avoided.
[0070] Next, each step of the compiling method 100 is described in detail.
[0071] In step S102, the file to be compiled and the configuration file are received in response to the preset file upload instruction of the client.
[0072] The compiling method 100 may be executed by a server. The server may first create a Web service to receive files uploaded by a client, wherein the files include, for example, files to be compiled and configuration files.
[0073] The file to be compiled is a project file, and the upload form thereof is, for example, package upload.
[0074] The configuration file may include, for example, a UUID field (project identifier), a specified project storage directory, and a specified port number to be exposed by the server. The configuration file is used to set the compilation environment, communication environment, and file storage environment, and its specific fields can be adjusted by technicians in this field according to actual conditions.
[0075] By identifying the UUID, you can determine whether the file to be compiled belongs to a new project. If it is a new project, install the corresponding dependencies and snapshot the current container. Otherwise, directly use the existing snapshot, run the command, and publish / generate.
[0076] In step S104, a persistent connection is established with the client in response to the persistent connection establishment request of the client.
[0077] After receiving the configuration file and determining the save directory of the files to be compiled and storing the files to be compiled according to the configuration file, the server waits for the client's persistent connection establishment request. After receiving the persistent connection establishment request, the server establishes a persistent connection with the client. At this time, the client's standard input and output (STD-IN / OUT) are connected to the socket of the persistent connection.
[0078] Socket is an abstract middleware layer for communication between the application layer and the TCP / IP protocol family, which can be understood as an interface. Two programs exchange data through a two-way communication connection, and one end of this connection is called a socket. A long connection means that during the entire communication process, the client and the server only use a pair of sockets and maintain the socket connection for a long time.
[0079] In the embodiment of the present disclosure, the long connection can be used to transmit the instructions from the client to the server (such as compilation instructions) and the feedback message from the server to the client instructions.
[0080] In step S106, a compilation environment image is selected from a plurality of compilation environment images according to the configuration file, a container is started according to the compilation environment image, and a control port of the container is connected to the persistent connection.
[0081] After establishing a persistent connection, you need to select an image to start the container. In the disclosed embodiment, the server saves images of multiple compilation environments, which can provide multiple choices for multiple users.
[0082] Figure 2It is a flowchart of selecting a compilation environment image according to an embodiment of the present disclosure.
[0083] refer to Figure 2 , step S106 may include:
[0084] Step S1061, determining the project identifier of the file to be compiled according to the configuration file;
[0085] Step S1062, determine whether the project identifier has a corresponding compilation environment image, if so, proceed to step S1063 to directly select the corresponding environment image, otherwise, proceed to step S1064 to determine whether the configuration file records the specified compilation environment image.
[0086] If yes, proceed to step S1065 to select the specified compilation environment image recorded in the configuration file; otherwise, proceed to step S1066 to select the default compilation environment image.
[0087] When the embodiments of the present disclosure are used for compiling front-end projects, the compilation environment image may include, for example, an image of the Angular development environment, an image of the React / React-native development environment, an image of the Vue environment, etc. When the embodiments of the present disclosure are used to compile other types of projects, more types of compilation environment images may also be included, and the present disclosure does not make any special limitations on this.
[0088] After selecting the compilation environment image, you can start the container according to the image and specify the shared directory between the container and the host as the save directory for the files to be compiled.
[0089] When starting a container, you can expose the container access port according to the configuration file settings, such as webpack-dev-server, etc., so that you can access the web service in the container through the port under a public domain name, which is convenient for multiple clients to view the compilation process and compilation results. For the client that issues the compilation instruction, you can also preview the compilation effect through the container access port, so as to send and modify the compilation instruction in time through the long connection.
[0090] In step S108, in response to the compile instruction sent by the client through the long connection, the compile instruction is executed on the file to be compiled within the container.
[0091] After starting the container, establishing the compilation environment, and loading the files to be compiled, you can connect the console input / output (STD-IN / STD-OUT) pipes in the container to the socket that is persistently connected to the server, receive and execute compilation instructions from the client, and send instruction execution results and other types of feedback messages (STD output) to the client through the persistent connection.
[0092] In step S110, in response to a preset compilation end instruction of the client, the long connection is disconnected and the container is recycled.
[0093] The end of the compilation needs to be led by the client. After receiving the preset compilation end instruction sent by the client, the server disconnects the long connection, recycles the container, returns the compilation result file to the client, and records the information of this compilation inside the server, such as the project identifier UUID and its corresponding compilation environment image, file storage directory, etc.
[0094] Corresponding to the above method, the present disclosure further provides a compilation system, including multiple clients and servers, and the server is used to execute the above compilation method 100.
[0095] Figure 3 It is a schematic diagram of the operation of the compilation system.
[0096] refer to Figure 3 , the compilation system 300 may include:
[0097] Server 31 is configured to execute the following instructions:
[0098] Step S102, responding to the preset file upload instruction of the client to receive the file to be compiled and the configuration file;
[0099] Step S104, responding to the client's persistent connection establishment request and establishing a persistent connection with the client;
[0100] Step S106, selecting a compilation environment image from multiple compilation environment images according to the configuration file, starting a container according to the compilation environment image, and connecting the control port of the container to the persistent connection;
[0101] Step S108, responding to the compile instruction sent by the client through the persistent connection, executing the compile instruction on the file to be compiled inside the container;
[0102] Step S110 , responding to the preset compilation end instruction of the client to disconnect the long connection and recycle the container.
[0103] Multiple clients 32 are coupled to the server 31, wherein each client 32 is configured to execute the following instructions:
[0104] Step S100, responding to a preset file acquisition instruction to locally acquire a file to be compiled and a configuration file;
[0105] Step S101, sending a preset file upload instruction to the server and then transmitting the file to be compiled and the configuration file;
[0106] Step S103, after the file is successfully transferred, a persistent connection establishment request is sent to the server to establish a persistent connection with the server;
[0107] Step S107, sending a compilation instruction formed according to the user operation to the server through a long connection;
[0108] Step S109: sending a preset compile end instruction in response to the user's preset operation.
[0109] In one embodiment, the workflow of the client 31 may be as follows: Figure 4A As shown, the workflow on the server side can be as follows Figure 4B As shown, the client 31 and the server 32 are both written in nodejs.
[0110] refer to Figure 4A ,In the compilation system 300, the main task of the client is to complete the ,interaction with the server and monitor the changes of local ,files.
[0111] In step S401, create a client project and configure package.json to expose the CLI command when it is installed globally. For example, specify the yg command as the client startup command, and the default client is yg below. Among them, CLI (command-line interface) is the most widely used user interface before the popularization of graphical user interfaces. It usually does not support a mouse. Users input commands through the keyboard, and the computer executes them after receiving the commands. Some people also call it a character user interface (CUI).
[0112] In step S402, when the user uses the yg command, it is detected whether there is a configuration file (hereinafter referred to as yg.config) in the local directory. If not, it is created. yg.confg contains a UUID field and the port number to be exposed by the specified server.
[0113] The UUID in yg.config is the project identifier. The same project is initialized only when it is uploaded for the first time to generate an image of the build environment for this project. When you execute commands in the future, the corresponding image will be used directly. Yg is the client CLI command used to start remote building in this solution. When yg is started, the following parameters will be analyzed by the client into shell commands and uploaded to the server.
[0114] In step S403, the local file is uploaded to the server, and monitoring of local file changes is started. When the local file changes, it will be incrementally uploaded to the server.
[0115] In step S404, a persistent connection is established with the server, and the client's standard input and output (STD-IN / OUT) are connected to the persistent socket connection.
[0116] In step S405, the compilation instruction is sent through the long connection, and the information returned through the long connection is displayed.
[0117] In step S406, the compilation is determined to be complete based on the user's action, and an end instruction is sent.
[0118] refer to Figure 4B The main task of the server is to create a suitable container environment through different images according to the yg.config sent by the client:
[0119] In step S411, firstly, a web service is created to accept files uploaded by the client, and the files are saved in a specified directory according to the configuration in yg.config.
[0120] In step S412, a long connection is established with the client (a socket connection is established).
[0121] In step S413, the compilation environment image is selected according to the yg.config configuration (if no image is specified in the configuration, the default image is used).
[0122] In step S414, the container is started using the image, and the shared directory between the container and the host is designated as the directory for storing the files uploaded by the client in the first step.
[0123] In step S415, port mapping is configured according to yg.config to expose the ports that need to be exposed in the container, such as webpack-dev-server, etc., so that the web service in the container can be accessed through the port under a public domain name.
[0124] In step S416, the console input / output (STD-IN / STD-OUT) pipe in the container is connected to the long connection of the client.
[0125] In step S417, the command input by the client is obtained and immediately executed inside the container
[0126] In step S418, during the execution of the container, all STD outputs are sent to the client through the long connection.
[0127] In step S419, the execution is completed, and the socket long connection is disconnected to recycle the container.
[0128] By using Docker (Docker is an open source application container engine that allows developers to package their applications and dependent packages into a portable container and then publish them to any popular Linux machine. It can also achieve virtualization. The container is completely sandboxed and there is no interface between them) technology, each front-end project can have its own build environment, and there is no need to deploy the same project multiple times when multiple people collaborate on development. The client interacts with the server through the socket, and each build is performed in a newly created container. The client is mainly responsible for local file operations and capturing client commands, and the server is responsible for scheduling containers and caching images.
[0129] Corresponding to the above method embodiment, the present disclosure also provides a compilation device, which can be used to execute the above method embodiment.
[0130] Figure 5 The following schematically shows a block diagram of a compiling device in an exemplary embodiment of the present disclosure.
[0131] refer to Figure 5 , the compiling device 500 may include:
[0132] The file receiving module 502 is configured to receive the to-be-compiled file and the configuration file in response to the preset file upload instruction of the client;
[0133] The connection module 504 is configured to establish a persistent connection with the client in response to a persistent connection establishment request from the client, and disconnect the persistent connection and recycle the container in response to a preset compilation end instruction from the client;
[0134] A container startup module 506, configured to select a compilation environment image from multiple compilation environment images according to the configuration file, start a container according to the compilation environment image, and connect the control port of the container to the persistent connection;
[0135] The file compiling module 508 is configured to respond to the compiling instruction sent by the client through the long connection and execute the compiling instruction on the file to be compiled within the container.
[0136] Since the functions of the device 500 have been described in detail in the corresponding method embodiments, the present disclosure will not elaborate on them here.
[0137] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0138] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0139] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "system".
[0140] Refer to the following Figure 6 The electronic device 600 according to this embodiment of the present invention is described. Figure 6 The electronic device 600 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0141] like Figure 6 As shown, the electronic device 600 is in the form of a general computing device. The components of the electronic device 600 may include but are not limited to: at least one processing unit 610, at least one storage unit 620, and a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610).
[0142] The storage unit stores program codes, which can be executed by the processing unit 610, so that the processing unit 610 performs the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification. For example, the processing unit 610 can perform the following steps: Figure 1 Steps S102 to S110 shown in FIG.
[0143] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .
[0144] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0145] Bus 630 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0146] The electronic device 600 may also communicate with one or more external devices 700 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 600, and / or communicate with any device that enables the electronic device 600 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 650. Furthermore, the electronic device 600 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 660. As shown, the network adapter 660 communicates with other modules of the electronic device 600 via a bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0147] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0148] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.
[0149] The program product may be in the form of a portable compact disk read-only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0150] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0151] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0152] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0153] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0154] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0155] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are to be considered exemplary only, and the true scope and concept of the present disclosure are indicated by the claims.
Claims
1. A compiling method, characterized in that: include: Respond to the preset file upload instruction of the client to receive the file to be compiled and the configuration file; Responding to the persistent connection establishment request of the client, establishing a persistent connection with the client; Selecting a compilation environment image from multiple compilation environment images according to the configuration file, starting a container according to the compilation environment image, and connecting the control port of the container to the persistent connection, and determining and exposing a container access port according to the configuration file to allow multiple clients to view the compilation process and compilation effect; In response to a compile instruction sent by the client through the persistent connection, executing the compile instruction on the file to be compiled within the container, and outputting a feedback message to the client through the persistent connection to allow the client to send a modified compile instruction through the persistent connection according to the feedback message; In response to a preset compilation end instruction of the client, the long connection is disconnected and the container is recycled.
2. The compiling method according to claim 1, characterized in that: The selecting a compilation environment image from multiple compilation environment images according to the configuration file includes: Determine the project identifier of the file to be compiled according to the configuration file; When a corresponding compilation environment image exists for the project identifier, directly selecting the corresponding environment image; Otherwise, select the specified compilation environment image recorded in the configuration file; When the configuration file does not record a specified compilation environment image, a default compilation environment image is selected.
3. The compiling method according to claim 1, characterized in that: Receiving the to-be-compiled file and the configuration file in response to the preset file upload instruction of the client includes determining a storage directory of the to-be-compiled file according to the configuration file, and starting the container according to the compilation environment image includes specifying a shared directory between the container and the host as the storage directory.
4. The compiling method according to claim 1, wherein: The executing the compile instruction on the file to be compiled within the container includes: The execution result of the compilation instruction is fed back to the client through the long connection.
5. A compilation system, characterized in that: include: The server is configured to execute the following instructions: Respond to the preset file upload instruction of the client to receive the file to be compiled and the configuration file; Responding to the persistent connection establishment request of the client, establishing a persistent connection with the client; Selecting a compilation environment image from multiple compilation environment images according to the configuration file, starting a container according to the compilation environment image, and connecting the control port of the container to the persistent connection, and determining and exposing a container access port according to the configuration file to allow multiple clients to view the compilation process and compilation effect; In response to a compile instruction sent by the client through the persistent connection, executing the compile instruction on the file to be compiled within the container, and outputting a feedback message to the client through the persistent connection to allow the client to send a modified compile instruction through the persistent connection according to the feedback message; In response to a preset compilation end instruction of the client, disconnect the long connection and recycle the container; A plurality of clients are coupled to the server, wherein each of the clients is configured to execute the following instructions: Responding to a preset file acquisition instruction, locally acquiring the file to be compiled and the configuration file; After sending the preset file upload instruction to the server, the file to be compiled and the configuration file are transmitted; After the file is successfully transferred, the persistent connection establishment request is sent to the server to establish the persistent connection with the server; Sending the compile instruction formed according to the user operation to the server through the long connection; Obtaining a feedback message corresponding to the compile instruction through the long connection, and sending a modified compile instruction through the long connection according to the feedback message; The preset compile end instruction is sent in response to the preset operation of the user.
6. The compilation system according to claim 5, characterized in that: The configuration file includes a project identifier of the file to be compiled, and the server is configured as follows: Determine the project identifier of the file to be compiled according to the configuration file; When a corresponding compilation environment image exists for the project identifier, directly selecting the corresponding environment image; Otherwise, select the specified compilation environment image recorded in the configuration file; When the configuration file does not record a specified compilation environment image, a default compilation environment image is selected.
7. The compilation system according to claim 5, characterized in that: Also includes: The client responds to the client startup command to determine whether there is a configuration file corresponding to the file to be compiled, and if not, creates the configuration file.
8. A compiling device, applied on a server side, characterized in that: include: A file receiving module, configured to receive files to be compiled and configuration files in response to a preset file upload instruction of a client; A connection management module, configured to establish a persistent connection with the client in response to a persistent connection establishment request from the client; and disconnect the persistent connection and recycle the container in response to a preset compilation end instruction from the client; A container startup module, configured to select a compilation environment image from multiple compilation environment images according to the configuration file, start a container according to the compilation environment image, connect the control port of the container to the persistent connection, and determine and expose the container access port according to the configuration file to allow multiple clients to view the compilation process and compilation effect; The file compilation module is configured to respond to the compilation instruction sent by the client through the persistent connection, execute the compilation instruction on the file to be compiled within the container, and output a feedback message to the client through the persistent connection to allow the client to send a modified compilation instruction through the persistent connection according to the feedback message.
9. An electronic device, characterized in that: include: Memory; as well as A processor coupled to the memory, wherein the processor is configured to execute the compiling method according to any one of claims 1 to 4 based on instructions stored in the memory.
10. A computer-readable storage medium having a program stored thereon, wherein when the program is executed by a processor, the compiling method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
A compiling and processing method and device under Linux
CN108984179A