Disclosure of Invention
The invention provides a method and a system for deploying and managing a web front-end project, which aim to overcome the defects of the prior art.
In one aspect, the present invention provides a method for web front-end project deployment management, the method comprising:
storing project information in a local JSON file form by utilizing a node.js fs module before starting a web front-end project, and reading the project information in the local JSON file to a memory when starting the web front-end project;
intercepting a request through a routing function of expressJS, receiving form information by using formulable, and performing operations including adding, deleting, modifying and searching on the project information in the memory according to the request and the form information;
according to the relevant information of the target server in the project information, remotely logging in the target server by using a node-ssh to obtain the operation authority of the target server;
intercepting a request packet dist.zip through a routing function of expressJS when a new version of a web front-end item is released, and backing up and deleting an item file of an old version in a target server by using node-ssh; secondly, uploading the request packet dist.zip sub-pieces to a project path used for storing the project information in the target server based on a sub-piece continuous transmission algorithm, and decompressing the request packet dist.zip;
annotating nodes needing to be managed in the Nginx configuration file by regular operation, when the nodes needing to be managed are managed, locating by searching for an anchor point, searching for the position of the nodes needing to be managed, and then performing operations including adding, deleting, modifying and searching on the nodes needing to be managed.
The method can realize lightweight release and management of the web front-end project, stores data in the form of the local JSON file without installing a database, and realizes quick and convenient Nginx installation on the web server and efficient configuration and modification of the installed Nginx server.
In a specific embodiment, the item information includes: account number, password, project path and Nginx profile path of the project server.
In a specific embodiment, the method performs the following steps when restoring the historical version of the web front-end item:
reading a version list of the web front-end project, selecting a historical version needing to be restored from the version list, backing up and filing a project file of a current version, renaming a backup folder of the historical version to a dist folder name of the current version, and recording information of the historical version.
In a specific embodiment, the annotating, by a canonical operation, the node insertion anchor point that needs to be managed in the nginnx configuration file includes:
constructing a matching regular expression for inserting anchor points: (ii)/location [ ^ } ] + }/gm;
and respectively inserting a start position anchor point and an end position anchor point into the start position and the end position of each node needing to be managed, and adding anchor point keywords to all anchor points.
In a specific embodiment, after the management of the node that needs to be managed is finished, the nginnx checksum restart is performed on the target server through node-ssh.
In a specific embodiment, the method further comprises: after remotely logging in the target server by using a node-ssh, obtaining a file stream of a configuration file from an nginx configuration file path in the project information through the node-ssh, storing the file stream in a local temporary file of the target server, transmitting the file stream to a user, and deleting the file stream in the local temporary file.
In a specific embodiment, the fragment resuming algorithm specifically includes the following steps:
determining the total number of fragments according to the file size of the request packet dist.zip and the preset fragment size, and marking each fragment with a corresponding fragment serial number;
determining a chunk starting interval and a chunk ending interval of each chunk according to the file size of the request packet dist.zip, the chunk sequence number and the preset chunk size;
when the number of the requests in the request packet dist.zip is less than or equal to the number of the CPU cores, the requests in the request packet dist.zip are uploaded in parallel;
when the number of the requests in the request packet dist.zip is greater than the number of the CPU cores, grouping the requests in the request packet dist.zip based on an async function and an await function of node.js and by using a chunk starting interval and a chunk ending interval of each fragment, wherein the number of the requests in each group is the number of the CPU cores;
and according to the grouping, the requests in each group are uploaded in parallel, the requests among different groups are uploaded in series, and the uploading progress is stored in the browser cache.
According to a second aspect of the present invention, a computer-readable storage medium is presented, having stored thereon a computer program which, when executed by a computer processor, implements the above-described method.
According to a third aspect of the present invention, a system for web front-end project deployment management is provided, the system comprising:
a data management module: the method comprises the steps that a configuration is used for storing project information in a local JSON file form by utilizing a node.js fs module before a web front-end project is started, and the project information in the local JSON file is read to a memory when the web front-end project is started;
the project management module: configuring a routing function intercepting request for passing through expressJS, receiving form information by using formulable, and performing operations including adding, deleting, modifying and searching on the project information in the memory according to the request and the form information;
ssh login module: the system is configured to remotely log in the target server by using a node-ssh according to the related information of the target server in the project information, and acquire the operation authority of the target server;
and a version management module: the method comprises the steps that a request packet is intercepted through a routing function of expressJS when a new version of a web front-end project is released, and node-ssh is used for backing up and deleting an old version of project file in a target server; secondly, uploading the request packet dist.zip sub-pieces to a project path used for storing the project information in the target server based on a sub-piece continuous transmission algorithm, and decompressing the request packet dist.zip;
a Nginx management module: the method comprises the steps that nodes needing to be managed in a Nginx configuration file are inserted into anchor points and annotated through regular operation, when the nodes needing to be managed are managed, the anchor points are searched for positioning, the positions of the nodes needing to be managed are searched, and then operations including adding, deleting, modifying and searching are carried out on the nodes needing to be managed.
Storing project information in a local JSON file form, and reading the project information in the local JSON file to a memory when a web front-end project is started; intercepting a request through a routing function of the expressJS, and receiving form information by utilizing formable to operate the project information in the memory; remotely logging in the target server by using a node-ssh to obtain the operation authority of the target server; intercepting a request packet (let. zip) through a routing function of expressJS when a new version of a web front-end item is released, and backing up and deleting an old version of item files in the target server by using node-ssh; uploading the request packet dist.zip sub-pieces to an item path used for storing the item information in the target server based on a sub-piece continuous transmission algorithm, and decompressing the request packet dist.zip; and annotating the node insertion anchor points needing to be managed in the Nginx configuration file through regular operation, so that the installed Nginx server is managed. The method can realize the lightweight release and management of the web front-end project, store data in the form of the local JSON file without installing a database, and realize the operations of quickly and conveniently installing the Nginx on the web server, efficiently configuring and modifying the installed Nginx server and the like.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
FIG. 1 illustrates an exemplary system architecture 100 to which a method for web front-end project deployment management of an embodiment of the present application may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. Various applications, such as a data processing application, a data visualization application, a web browser application, etc., may be installed on the terminal devices 101, 102, 103.
The terminal apparatuses 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices including, but not limited to, smart phones, tablet computers, laptop portable computers, desktop computers, and the like. When the terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. It may be implemented as a plurality of software or software modules (e.g., software or software modules used to provide distributed services) or as a single software or software module. And is not particularly limited herein.
The server 105 may be a server that provides various services, such as a background information processing server that provides support for project information presented on the terminal devices 101, 102, 103. The background information processing server can process the acquired project information and generate a processing result (such as a local JSON file).
It should be noted that the method provided in the embodiment of the present application may be executed by the server 105, or may be executed by the terminal devices 101, 102, and 103, and the corresponding apparatus is generally disposed in the server 105, or may be disposed in the terminal devices 101, 102, and 103.
The server may be hardware or software. When the server is hardware, it may be implemented as a distributed server cluster composed of multiple servers, or may be implemented as a single server. When the server is software, it may be implemented as multiple pieces of software or software modules (e.g., software or software modules used to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Fig. 2 shows a flowchart of a method for web front-end project deployment management according to an embodiment of the present invention. As shown in fig. 2, the method comprises the steps of:
201: and storing the project information in a local JSON file form by utilizing a node.js fs module before starting the web front-end project, and reading the project information in the local JSON file to a memory when starting the web front-end project.
In a specific embodiment, the item information includes: account number, password, project path and Nginx profile path of the project server.
202: intercepting a request through a routing function of expressJS, receiving form information by using formenable, and performing operations including adding, deleting, modifying and searching on the item information in the memory according to the request and the form information.
203: and according to the related information of the target server in the project information, remotely logging in the target server by using a node-ssh to obtain the operation authority of the target server.
In a specific embodiment, the method further comprises: after remotely logging in the target server by using a node-ssh, obtaining a file stream of a configuration file from an nginx configuration file path in the project information through the node-ssh, storing the file stream in a local temporary file of the target server, transmitting the file stream to a user, and deleting the file stream in the local temporary file.
204: intercepting a request packet (let. zip) through a routing function of expressJS when a new version of a web front-end item is released, and backing up and deleting an old version of item files in the target server by using node-ssh; and then, based on a fragment continuous transmission algorithm, uploading the request packet dist.zip fragments to a project path used for storing the project information in the target server, and decompressing the request packet dist.zip.
In a specific embodiment, the fragment resuming algorithm specifically includes the following steps:
determining the total number of fragments according to the file size of the request packet dist.zip and the preset fragment size, and marking each fragment with a corresponding fragment serial number;
determining a chunk starting interval and a chunk ending interval of each chunk according to the file size of the request packet dist.zip, the chunk sequence number and the preset chunk size;
when the number of the requests in the request packet dist.zip is less than or equal to the number of the CPU cores, the requests in the request packet dist.zip are uploaded in parallel;
when the number of the requests in the request packet dist.zip is greater than the number of the CPU cores, grouping the requests in the request packet dist.zip based on the async function and the await function of node.js and by using the chunk starting interval and the chunk ending interval of each fragment, wherein the number of the requests in each group is the number of the CPU cores;
and according to the grouping, the requests in each group are uploaded in parallel, the requests among different groups are uploaded in series, and the uploading progress is stored in the browser cache.
In a specific embodiment, the program code of the fragment continuous transmission algorithm is as follows:
205: annotating nodes needing to be managed in the Nginx configuration file by regular operation, when the nodes needing to be managed are managed, locating by searching for an anchor point, searching for the position of the nodes needing to be managed, and then performing operations including adding, deleting, modifying and searching on the nodes needing to be managed.
In a specific embodiment, after the management of the node that needs to be managed is finished, the nginnx checksum restart is performed on the target server through node-ssh.
In a specific embodiment, the annotating, by a canonical operation, the node insertion anchor point that needs to be managed in the nginnx configuration file includes:
constructing a matching regular expression for inserting anchor points: (ii)/location [ ^ } ] + }/gm;
and respectively inserting a start position anchor point and an end position anchor point into the start position and the end position of each node to be managed, and adding anchor point keywords to all anchor points.
In a preferred embodiment, the format for inserting an anchor point into the content of a node may be represented using the following expression:
type # - [ start ] - [ id ] node content # - [ type ] - [ end ] - [ id ].
In a preferred embodiment, finding an anchor point is implemented by the following two position expressions:
position where anchor starts: indexof ("[ $ { type } ] - [ start ] - [ $ { id } ]');
position where anchor point ends: s.indexof ("[ $ { type } ] - [ end ] - [ $ { id } ]').
In a preferred embodiment, the specific algorithmic program code used by the anchor point is as follows:
in a specific embodiment, the method performs the following steps when restoring the historical version of the web front-end item:
reading a version list of the web front-end project, selecting a historical version needing to be restored from the version list, backing up and filing a project file of a current version, renaming a backup folder of the historical version to a dist folder name of the current version, and recording information of the historical version.
FIG. 3 illustrates a framework diagram of a system for web front-end project deployment management, according to an embodiment of the invention. The system includes a data management module 301, a project management module 302, a ssh login module 303, a version management module 304, and a Nginx management module 305.
In a specific embodiment, the data management module 301 is configured to store the project information in the form of a native JSON file by using a node.js fs module before a web front-end project is started, and read the project information in the native JSON file to a memory when the web front-end project is started;
the project management module 302 is configured to intercept a request through a routing function of expressJS, receive form information by using formenable, and perform operations including adding, deleting, modifying and searching on the project information in the memory according to the request and the form information;
the ssh login module 303 is configured to remotely log in to the target server by using a node-ssh according to the related information of the target server in the project information, and obtain an operation right on the target server;
the version management module 304 is configured to intercept a request packet dist.zip through a routing function of expressJS when a new version of a web front-end item is released, and backup and delete an old version of an item file in the target server by using node-ssh; secondly, uploading the request packet dist.zip sub-pieces to a project path used for storing the project information in the target server based on a sub-piece continuous transmission algorithm, and decompressing the request packet dist.zip;
the Nginx management module 305 is configured to annotate, through regular operation, an insertion anchor of a node to be managed in a Nginx configuration file, locate, search for a location of the node to be managed by searching for the anchor when managing the node to be managed, and perform operations including adding, deleting, modifying and searching on the node to be managed.
The system can realize the lightweight release and management of the web front-end project, stores data in the form of local JSON files without installing a database, and realizes the operations of quickly and conveniently installing Nginx on the web server, efficiently configuring and modifying the installed Nginx server and the like.
Referring now to FIG. 4, shown is a block diagram of a computer system 400 suitable for use in implementing the electronic device of an embodiment of the present application. The electronic device shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 4, the computer system 400 includes a Central Processing Unit (CPU)401 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage section 408 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the system 400 are also stored. The CPU 401, ROM 402, and RAM 403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
The following components are connected to the I/O interface 405: an input section 406 including a keyboard, a mouse, and the like; an output section 407 including a display such as a Liquid Crystal Display (LCD) and a speaker; a storage section 408 including a hard disk and the like; and a communication section 409 including a network interface card such as a LAN card, a modem, or the like. The communication section 409 performs communication processing via a network such as the internet. A driver 410 is also connected to the I/O interface 405 as needed. A removable medium 411 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 410 as necessary, so that a computer program read out therefrom is mounted into the storage section 408 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 409, and/or installed from the removable medium 411. The computer program performs the above-described functions defined in the method of the present application when executed by a Central Processing Unit (CPU) 401. It should be noted that the computer readable storage medium described herein can 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 application, 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 this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, 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 also be any computer readable storage 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 storage medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. 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 that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present application may be implemented by software or hardware. The units described may also be provided in a processor, and the names of the units do not in some cases constitute a limitation of the unit itself.
Embodiments of the present invention also relate to a computer-readable storage medium having stored thereon a computer program which, when executed by a computer processor, implements the method above. The computer program comprises program code for performing the method illustrated in the flow chart. Note that the computer readable medium of the present application can be a computer readable signal medium or a computer readable medium or any combination of the two.
Storing project information in a local JSON file form, and reading the project information in the local JSON file to a memory when a web front-end project is started; intercepting a request through a routing function of the expressJS, and receiving form information by utilizing formable to operate the project information in the memory; remotely logging in the target server by using a node-ssh to obtain the operation authority of the target server; intercepting a request packet (let. zip) through a routing function of expressJS when a new version of a web front-end item is released, and backing up and deleting an old version of item files in the target server by using node-ssh; uploading the request packet dist.zip sub-pieces to an item path used for storing the item information in the target server based on a sub-piece continuous transmission algorithm, and decompressing the request packet dist.zip; and annotating the node insertion anchor points needing to be managed in the Nginx configuration file through regular operation, so that the installed Nginx server is managed. The method can realize the lightweight release and management of the web front-end project, store data in the form of the local JSON file without installing a database, and realize the operations of quickly and conveniently installing the Nginx on the web server, efficiently configuring and modifying the installed Nginx server and the like.
The above description is only a preferred embodiment of the application 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 invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the invention. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.