Process identification method and apparatus, and electronic device
By receiving and processing process query and startup instructions, obtaining and matching paths to determine the absolute path of the process, the problem of low process recognition efficiency in the prior art is solved, and precise identification and control of the process is realized.
Patent Information
- Application Number
- CN202410945492.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-15
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2044-07-15
AI Technical Summary
The prior art cannot achieve accurate identification and control of processes, especially in the case of nginx processes, the recognition efficiency and accuracy are low.
By receiving process query instructions and process startup instructions, obtaining process identification information and paths, using the virtual file system to obtain absolute paths, and matching relative paths to determine the absolute paths of the process, thereby achieving accurate process identification and control.
Accurate identification and control of processes is achieved, the problem of inability to achieve accurate identification and control in the existing technology is solved, and the efficiency and accuracy of process management are improved.
Smart Images

Figure CN118885998A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a process identification method, device and electronic equipment. Background Art
[0002] Usually, multiple processes are run on the host at the same time, and these processes are started with different working paths and execution paths. To achieve accurate management of processes, the first thing that needs to be achieved is accurate identification of processes. The inventor found that the currently used method for identifying processes usually relies on the method of searching for executable programs that comes with the operating system, but this method that relies on the search for executable programs that comes with the operating system usually has low efficiency in identifying processes. Taking the nginx process as an example, when the directory of the nginx process is added to the PATH environment variable and the user directly enters the command "nginx" in the operating system to start the nginx process, the efficiency and accuracy of the prior art in identifying the nginx process are very low, and it is also difficult to achieve accurate control of the nginx process. In summary, the prior art still has the problem of being unable to achieve accurate identification and control of processes. Summary of the invention
[0003] The embodiments of the present invention provide a method, device and electronic device for process identification, which are used to solve the problem that the prior art cannot accurately identify and control the process.
[0004] The specific technical solutions are as follows:
[0005] In a first aspect, an embodiment of the present invention provides a method for process identification, the method being applied to a virtual machine or a hardware server, comprising the following steps:
[0006] Respectively receiving a process query instruction and an instruction for obtaining a process start instruction; wherein the process start instruction is an instruction input when starting a process;
[0007] According to the process query instruction, a process in the running state is identified as a process to be identified, and identification information of the process to be identified is obtained;
[0008] According to the instruction for obtaining a process start instruction, obtain a process start instruction of the process to be identified; wherein the process start instruction of the process to be identified includes: a start instruction of an executable file corresponding to the process to be identified, and a start instruction of a configuration file corresponding to the process to be identified; the start instruction of the executable file includes a path of the executable file; the start instruction of the configuration file includes a path of the configuration file;
[0009] Obtaining the paths of the executable file and configuration file corresponding to the process to be identified from the process startup instruction of the process to be identified;
[0010] When the paths of the executable file and the configuration file obtained from the process startup instruction of the process to be identified are both relative paths, obtaining the absolute path of the executable file corresponding to the process to be identified from the virtual file system according to the identification information of the process to be identified;
[0011] Matching the absolute path of the executable file corresponding to the process to be identified with the relative path of the executable file corresponding to the process to be identified, and determining the current directory of the relative path of the executable file;
[0012] Determine the parent directory of the relative path of the executable file according to the current directory of the relative path of the executable file;
[0013] Determine the absolute path of the configuration file corresponding to the process to be identified according to the upper-level directory of the relative path of the executable file;
[0014] The process to be identified is identified according to the absolute paths of the executable file and the configuration file corresponding to the process to be identified.
[0015] Optionally, the method further includes:
[0016] When the paths of the executable file and the configuration file in the process startup instruction of the process to be identified are absolute paths, the absolute paths of the executable file and the configuration file are obtained, and the process to be identified is identified according to the absolute paths of the executable file and the configuration file.
[0017] Optionally, the steps of respectively receiving a process query instruction and receiving an instruction for obtaining a process start instruction include:
[0018] Receive the process query command and the nginx process startup command respectively.
[0019] Optionally, the step of identifying a process in a running state in itself as a process to be identified according to the process query instruction, and obtaining identification information of the process to be identified includes:
[0020] According to the process query instruction, the nginx process in the running state is confirmed as the process to be identified, and the identification information of the process to be identified is obtained.
[0021] Optionally, before the step of acquiring the process startup instruction of the process to be identified according to the instruction of acquiring the process startup instruction, the step further includes:
[0022] Receive a process start instruction issued by a user, start a corresponding process according to the process start instruction, and save the process start instruction.
[0023] In a second aspect, an embodiment of the present invention provides a process identification device, the device comprising:
[0024] An instruction receiving module, used to receive a process query instruction and an instruction to obtain a process start instruction respectively; wherein the process start instruction is an instruction input when starting a process;
[0025] A confirmation module, configured to confirm a process in a running state in itself as a process to be identified according to the process query instruction, and obtain identification information of the process to be identified;
[0026] An instruction acquisition module, used to acquire the process startup instruction of the process to be identified according to the instruction for acquiring the process startup instruction; wherein the process startup instruction of the process to be identified includes: a startup instruction of an executable file corresponding to the process to be identified, and a startup instruction of a configuration file corresponding to the process to be identified; the startup instruction of the executable file includes a path of the executable file; the startup instruction of the configuration file includes a path of the configuration file;
[0027] A path acquisition module, used to acquire the path of the executable file and configuration file corresponding to the process to be identified from the process startup instruction of the process to be identified;
[0028] an acquisition module, configured to acquire, from a virtual file system, an absolute path of the executable file corresponding to the process to be identified, according to the identification information of the process to be identified, when the paths of the executable file and the configuration file obtained from the process startup instruction of the process to be identified are both relative paths;
[0029] A matching module, used for matching the absolute path of the executable file corresponding to the process to be identified with the relative path of the executable file corresponding to the process to be identified, and determining the current directory of the relative path of the executable file;
[0030] A first determining module, configured to determine the upper directory of the relative path of the executable file according to the current directory of the relative path of the executable file;
[0031] A second determination module is used to determine the absolute path of the configuration file corresponding to the process to be identified according to the upper directory of the relative path of the executable file;
[0032] The identification module is used to identify the process to be identified according to the absolute paths of the executable file and configuration file corresponding to the process to be identified.
[0033] Optionally, the Get module is also used to:
[0034] When the paths of the executable file and the configuration file in the process start instruction of the process to be identified are absolute paths, the absolute paths of the executable file and the configuration file are obtained, and the identification module is started.
[0035] Optionally, the instruction receiving module is specifically used to:
[0036] Receive the process query command and the nginx process startup command respectively.
[0037] Optional, confirmation module, specifically used for:
[0038] According to the process query instruction, the nginx process in the running state is confirmed as the process to be identified, and the identification information of the process to be identified is obtained.
[0039] Optionally, the device further includes: a startup saving module, configured to:
[0040] Receive a process start instruction issued by a user, start a corresponding process according to the process start instruction, and save the process start instruction.
[0041] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0042] The memory is used to store computer programs;
[0043] The processor is used to implement the method steps of process identification described in the first aspect when executing the program stored in the memory.
[0044] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps for process identification described in the first aspect are implemented.
[0045] The process identification method provided by the embodiment of the present invention is applied to a virtual machine or a hardware server, and can realize receiving a process query instruction and receiving an instruction for obtaining a process start instruction respectively; according to the process query instruction, confirming a process in a running state in itself as a process to be identified, and obtaining identification information of the process to be identified; according to the instruction for obtaining a process start instruction, obtaining a process start instruction of the process to be identified; obtaining the path of the executable file and the configuration file corresponding to the process to be identified from the process start instruction of the process to be identified; when the paths of the executable file and the configuration file obtained from the process start instruction of the process to be identified are both relative paths, obtaining the absolute path of the executable file corresponding to the process to be identified from the virtual file system according to the identification information of the process to be identified; matching the absolute path of the executable file corresponding to the process to be identified with the relative path of the executable file corresponding to the process to be identified, and determining the current directory of the relative path of the executable file; determining the upper directory of the relative path of the executable file according to the current directory of the relative path of the executable file; determining the absolute path of the configuration file corresponding to the process to be identified according to the upper directory of the relative path of the executable file; identifying the process to be identified according to the absolute paths of the executable file and the configuration file corresponding to the process to be identified. It can be seen that, in the process startup instruction of the process to be identified, when the paths of the executable file and the configuration file are both relative paths, the absolute path of the configuration file can still be obtained using the method provided by the embodiment of the present invention, and then, a process in a running state can be uniquely determined based on the absolute paths of the executable file and the configuration file of the process. In other words, the method provided by the embodiment of the present invention can realize accurate identification of the process, and then can realize accurate control of the process. In summary, the method provided by the embodiment of the present invention can solve the problem that the prior art cannot realize accurate identification and control of the process.
[0046] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings.
[0047] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0049] Figure 1 A schematic diagram of a process identification method provided by an embodiment of the present invention;
[0050] Figure 2 Another schematic flow chart of a method for process identification provided by an embodiment of the present invention;
[0051] Figure 3 A schematic diagram of the structure of a process identification device provided by an embodiment of the present invention;
[0052] Figure 4 A schematic diagram of the internal structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0054] Figure 1 A flowchart of a method for identifying a process provided by an embodiment of the present invention is shown. The method provided by an embodiment of the present invention is applied to a virtual machine or a hardware server, such as Figure 1 As shown, the method includes:
[0055] S101: receiving a process query instruction and receiving an instruction for obtaining a process start instruction respectively; wherein the process start instruction is an instruction input when starting a process;
[0056] In a specific embodiment, the steps of respectively receiving a process query instruction and receiving an instruction to obtain a process start instruction may include:
[0057] Receive the process query command and the nginx process startup command respectively.
[0058] nginx (engine X) is a lightweight, high-performance HTTP server and reverse proxy server, as well as an IMAP / POP3 / SMTP proxy server.
[0059] In actual applications, users can enter the command in the operating system of the virtual machine or hardware server: ps aux|grep'nginx:master process' to query the running processes in the operating system of the virtual machine or hardware server, filter out the running information of the nginx master process, and obtain the startup instruction of the nginx process.
[0060] S102: According to the process query instruction, a process in the running state is identified as a process to be identified, and identification information of the process to be identified is obtained;
[0061] The "self" here refers to the operating system of the virtual machine or hardware server, which can be the Linux operating system in a specific embodiment.
[0062] In a specific embodiment, according to the process query instruction, the step of identifying a process in a running state as a process to be identified and obtaining identification information of the process to be identified may include:
[0063] According to the process query instruction, the nginx process in the running state is confirmed as the process to be identified, and the identification information of the process to be identified is obtained.
[0064] S103: According to the instruction for obtaining a process start instruction, obtain a process start instruction of the process to be identified; wherein the process start instruction of the process to be identified includes: a start instruction of an executable file corresponding to the process to be identified, and a start instruction of a configuration file corresponding to the process to be identified; the start instruction of the executable file includes a path of the executable file; the start instruction of the configuration file includes a path of the configuration file;
[0065] Each nginx process has its own executable file, working path and configuration file. The executable file is the nginx program, which indicates who the process is and which program it is. The working path indicates where the root directory of the current process is. The configuration file determines what kind of services the process can provide.
[0066] In practical applications, before the step of obtaining the process start instruction of the process to be identified according to the instruction of obtaining the process start instruction, the following steps may also be included:
[0067] Receive a process start instruction issued by a user, start a corresponding process according to the process start instruction, and save the process start instruction.
[0068] S104: Obtaining the path of the executable file and configuration file corresponding to the process to be identified from the process start instruction of the process to be identified;
[0069] S105: when the paths of the executable file and the configuration file obtained from the process startup instruction of the process to be identified are both relative paths, obtaining the absolute path of the executable file corresponding to the process to be identified from the virtual file system according to the identification information of the process to be identified;
[0070] In a specific embodiment, the method provided by the embodiment of the present invention further includes:
[0071] When the paths of the executable file and the configuration file in the process startup instruction of the process to be identified are absolute paths, the absolute paths of the executable file and the configuration file are obtained, and the process to be identified is identified according to the absolute paths of the executable file and the configuration file.
[0072] The absolute path of the executable file and configuration file of the ngnix process can uniquely determine a running ngnix process.
[0073] Users must use the process start command to start the nginx process. There are usually three ways to start the nginx process:
[0074] 1. Use the absolute path of the nginx process to start the nginx process, that is, the process startup instruction includes: the absolute path of the executable file and configuration file corresponding to the nginx process. In this case, the method provided by the embodiment of the present invention only needs to directly obtain the absolute path of the executable file and configuration file corresponding to the nginx process from the process startup instruction; and then identify the nginx process according to the absolute path of the executable file and configuration file corresponding to the nginx process.
[0075] 2. Start the nginx process using the relative path of the nginx process. In this case, the method provided in the embodiment of the present invention can obtain the absolute path of the executable file and configuration file corresponding to the nginx process from the virtual file system according to the identification information of the nginx process; and then identify the nginx process according to the absolute path of the executable file and configuration file corresponding to the nginx process. In a specific embodiment, the absolute path of the executable file and configuration file corresponding to the nginx process can be obtained from the proc file system (a virtual file system) according to the identification information of the nginx process.
[0076] 3. When the directory where the nginx process is located is added to the PATH environment variable, the user directly enters the command "nginx" in the operating system to start the nginx process. In this case, the method provided by the embodiment of the present invention needs to first obtain the absolute path of the executable file of the nginx process from the virtual file system according to the identification information of the nginx process; then perform string matching on the absolute path of the executable file of the nginx process and the relative path of the executable file of the nginx process to determine the current directory of the relative path of the executable file of the nginx process, wherein the relative path of the executable file of the nginx process is obtained from the process startup instruction corresponding to the nginx process; according to the current directory of the relative path of the executable file of the nginx process, determine the upper directory of the relative path of the executable file of the nginx process; according to the upper directory of the relative path of the executable file of the nginx process, determine the absolute path of the configuration file of the nginx process; and then identify the nginx process according to the absolute paths of the executable file and the configuration file corresponding to the nginx process. The PATH environment variable stores a specific path in the system cache. When you need to run some programs, the system will first start looking for and running them from the current path. If it cannot find the file, it will enter the path specified by the path to find the corresponding file and run it.
[0077] S106: Matching the absolute path of the executable file corresponding to the process to be identified with the relative path of the executable file corresponding to the process to be identified, and determining the current directory of the relative path of the executable file;
[0078] In another specific embodiment, the character string of the absolute path of the executable file of the nginx process is matched with the character string of the relative address of the executable file of the nginx process to determine the current directory of the relative path of the executable file of the nginx process.
[0079] Absolute path: directly indicates the specific location of the file on the hard disk or the complete path based on the root directory of the Web site. The absolute path is a fixed directory, which is intuitive and clear, but the files referenced by the web page cannot be moved at will. When multiple web pages reference the same file, the absolute path used is the same.
[0080] Relative path: Omits disk drive letter, computer name and other information, and uses the folder location of the web page that references the file as a reference to establish a base root directory. When web pages saved in different directories reference the same file, the relative paths used are different. In a relative path:
[0081] / represents the root directory;
[0082] . / represents the directory where the current file is located (can be omitted);
[0083] ... / represents the parent directory of the directory where the current file is located;
[0084] ... / ... / represents the parent directory of the current file;
[0085] ... / ... / ... / and so on.
[0086] S107: Determine the parent directory of the relative path of the executable file according to the current directory of the relative path of the executable file;
[0087] S108: Determine the absolute path of the configuration file corresponding to the process to be identified according to the upper directory of the relative path of the executable file;
[0088] S109: Identify the process to be identified according to the absolute paths of the executable file and configuration file corresponding to the process to be identified.
[0089] Depend on Figure 1It can be seen that the process identification method provided by the embodiment of the present invention is applied to a virtual machine or a hardware server, and can respectively receive a process query instruction and an instruction for receiving a process startup instruction; according to the process query instruction, a process in a running state in itself is confirmed as a process to be identified, and identification information of the process to be identified is obtained; according to the instruction for obtaining a process startup instruction, a process startup instruction of the process to be identified is obtained; from the process startup instruction of the process to be identified, the path of the executable file and the configuration file corresponding to the process to be identified is obtained; when the paths of the executable file and the configuration file obtained from the process startup instruction of the process to be identified are both relative paths, According to the identification information of the process to be identified, the absolute path of the executable file corresponding to the process to be identified is obtained from the virtual file system; the absolute path of the executable file corresponding to the process to be identified is matched with the relative path of the executable file corresponding to the process to be identified, and the current directory of the relative path of the executable file is determined; according to the current directory of the relative path of the executable file, the upper directory of the relative path of the executable file is determined; according to the upper directory of the relative path of the executable file, the absolute path of the configuration file corresponding to the process to be identified is determined; according to the absolute path of the executable file and the configuration file corresponding to the process to be identified, the process to be identified is identified. It can be seen that in the process startup instruction of the process to be identified, when the paths of the executable file and the configuration file are both relative paths, the absolute path of the configuration file can still be obtained by using the method provided by the embodiment of the present invention, and then, a process in a running state is uniquely determined according to the absolute path of the executable file and the configuration file of the process. That is to say, the method provided by the embodiment of the present invention can realize accurate identification of the process, and then can realize accurate control of the process. In summary, it can be seen that the method provided by the embodiment of the present invention can solve the problem that accurate identification and control of the process cannot be realized in the prior art.
[0090] The following is a practical example to further illustrate the method provided by the embodiment of the present invention in more detail. In this embodiment, the execution subject of the method provided by the embodiment of the present invention is a hardware server, and the operating system of the hardware server is a Linux operating system; the process to be identified in this embodiment is a running nginx process; and in this embodiment, the directory where the nginx process is located is added to the PATH environment variable. Figure 2 , the process of this embodiment is as follows:
[0091] S201: receiving a process query instruction and receiving an instruction for obtaining an nginx process start instruction respectively;
[0092] The process start instruction is the instruction input when starting the process.
[0093] For example, the user can enter the command in the operating system of the virtual machine or hardware server: ps aux|grep'nginx:master process' to query the running processes in the hardware server operating system, filter out the running information of the nginx master process, and obtain the startup instruction of the nginx process.
[0094] S202: According to the process query instruction, the nginx process in the running state is identified as the process to be identified, and the identification information of the nginx process to be identified is obtained;
[0095] Specifically, according to the process query instruction, the operating system of the hardware server identifies the nginx process in the operating state as the process to be identified, and obtains the identification information of the nginx process to be identified.
[0096] Of course, there may be multiple nginx processes running in the operating system, so it is necessary to obtain all the nginx processes running in the operating system and identify them as nginx processes to be identified.
[0097] S203: According to the instruction for obtaining a process start instruction, obtain a process start instruction of the nginx process to be identified;
[0098] Among them, the process startup instruction of the nginx process includes: the startup instruction of the executable file corresponding to the nginx process, the startup instruction of the configuration file corresponding to the nginx process; the startup instruction of the executable file includes the path of the executable file; the startup instruction of the configuration file includes the path of the configuration file.
[0099] Of course, in actual applications, when a user initiates a process start instruction to the operating system, the process start instruction will be saved for subsequent use.
[0100] S204: Obtaining the path of the executable file and configuration file of the nginx process to be identified from the process startup instruction of the nginx process to be identified;
[0101] In this embodiment, in the process startup instruction of the nginx process to be identified, the paths of the executable file and the configuration file are relative paths, so steps S205-S209 need to be executed.
[0102] In other embodiments, if the paths of the executable file and the configuration file in the process startup instruction of the nginx process to be identified are both absolute paths, then the absolute paths of the executable file and the configuration file of the nginx process to be identified are obtained directly from the process startup instruction of the nginx process to be identified, and the nginx process to be identified is identified according to the absolute paths of the executable file and the configuration file of the nginx process to be identified.
[0103] S205: According to the identification information of the nginx process to be identified, the absolute path of the executable file corresponding to the nginx process to be identified is obtained from the proc file system;
[0104] Specifically, the absolute path of the executable file corresponding to the nginx process is a character string. For example, the absolute path is: user / srod / nginx.
[0105] S206: Match the absolute path of the executable file of the ngnix process to be identified with the relative path of the executable file of the ngnix process to be identified, and determine the current directory of the relative path of the executable file of the ngnix process to be identified;
[0106] For example, in the process startup instruction of the nginx process to be identified (in this embodiment, the paths of the executable file and the configuration file in the process startup instruction of the nginx process are relative paths), the paths of the executable file and the configuration file are: . / srod / nginx (relative path of the executable file); .. / edx / nginx (relative path of the configuration file). The absolute path of the executable file: user / srod / nginx is matched with the relative path of the executable file: . / srod / nginx, and the current directory of the relative path of the executable file of the ngnix process to be identified is determined to be: user.
[0107] S207: Determine the parent directory of the relative path of the executable file of the ngnix process to be identified according to the current directory of the relative path of the executable file of the ngnix process to be identified;
[0108] For example, according to the current directory "user" of the relative path of the executable file of the ngnix process to be identified, the parent directory of the relative path of the executable file of the ngnix process to be identified is determined.
[0109] S208: Determine the absolute path of the configuration file of the ngnix process to be identified according to the upper-level directory of the relative path of the executable file of the ngnix process to be identified;
[0110] S209: The ngnix process to be identified is identified according to the absolute path of the executable file and the configuration file of the ngnix process to be identified.
[0111] In actual applications, after accurately identifying the ngnix process, you can further control the ngnix process according to actual needs. For example, you can manage Nginx in the following ways: restart, start, force shutdown, soft shutdown, reload configuration, smooth upgrade, upgrade rollback, output existing configuration or verify configuration positivity, etc. Only by accurately identifying the nginx process can you achieve accurate control of the nginx process. Otherwise, it is possible to perform incorrect operations on the nginx process, such as shutting down an nginx process that should not be shut down, etc. The original service of the nginx process that is incorrectly operated will stop after being shut down. If it is in a production environment, such an incorrect operation will cause a production accident. Therefore, it is necessary to accurately control the nginx process.
[0112] Depend on Figure 2 It can be seen from the illustrated embodiment that, in the process startup instruction of the process to be identified, when the paths of the executable file and the configuration file are both relative paths, the absolute path of the configuration file can still be obtained using the method provided by the embodiment of the present invention, and then, a process in a running state can be uniquely determined based on the absolute paths of the executable file and the configuration file of the process. In other words, the method provided by the embodiment of the present invention can realize accurate identification of the process, and further can realize accurate control of the process. In summary, it can be seen that the method provided by the embodiment of the present invention can solve the problem that the prior art cannot realize accurate identification and control of the process.
[0113] and Figure 1 Corresponding to the embodiment shown in FIG. 1 , the embodiment of the present invention further provides a device for process identification. Figure 3 As shown, the device includes: an instruction receiving module 301, a confirmation module 302, an instruction obtaining module 303, a path obtaining module 304, an obtaining module 305, a matching module 306, a first determining module 307, a second determining module 308, and an identification module 309, wherein:
[0114] The instruction receiving module 301 is used to receive a process query instruction and an instruction to obtain a process start instruction respectively; wherein the process start instruction is an instruction input when starting a process;
[0115] The confirmation module 302 is used to confirm the running process in itself as the process to be identified according to the process query instruction, and obtain the identification information of the process to be identified;
[0116] The instruction acquisition module 303 is used to acquire the process startup instruction of the process to be identified according to the instruction of acquiring the process startup instruction; wherein the process startup instruction of the process to be identified includes: the startup instruction of the executable file corresponding to the process to be identified, and the startup instruction of the configuration file corresponding to the process to be identified; the startup instruction of the executable file includes the path of the executable file; the startup instruction of the configuration file includes the path of the configuration file;
[0117] The path acquisition module 304 is used to acquire the path of the executable file and the configuration file corresponding to the process to be identified from the process startup instruction of the process to be identified;
[0118] The acquisition module 305 is used to acquire the absolute path of the executable file corresponding to the process to be identified from the virtual file system according to the identification information of the process to be identified when the paths of the executable file and the configuration file obtained from the process startup instruction of the process to be identified are both relative paths;
[0119] A matching module 306 is used to match the absolute path of the executable file corresponding to the process to be identified with the relative path of the executable file corresponding to the process to be identified, and determine the current directory of the relative path of the executable file;
[0120] A first determining module 307, configured to determine the parent directory of the relative path of the executable file according to the current directory of the relative path of the executable file;
[0121] The second determination module 308 is used to determine the absolute path of the configuration file corresponding to the process to be identified according to the upper directory of the relative path of the executable file;
[0122] The identification module 309 is used to identify the process to be identified according to the absolute paths of the executable file and configuration file corresponding to the process to be identified.
[0123] Optionally, the acquisition module 305 is further used to:
[0124] When the paths of the executable file and the configuration file in the process start instruction of the process to be identified are absolute paths, the absolute paths of the executable file and the configuration file are obtained, and the identification module 309 is started.
[0125] Optionally, the instruction receiving module 301 is specifically used for:
[0126] Receive the process query command and the nginx process startup command respectively.
[0127] Optionally, the confirmation module 302 is specifically configured to:
[0128] According to the process query instruction, the nginx process in the running state is confirmed as the process to be identified, and the identification information of the process to be identified is obtained.
[0129] Optionally, the device further includes: a startup saving module, configured to:
[0130] Receive a process start instruction issued by a user, start a corresponding process according to the process start instruction, and save the process start instruction.
[0131] Depend on Figure 3 It can be seen from the illustrated embodiment that, in the process startup instruction of the process to be identified, when the paths of the executable file and the configuration file are both relative paths, the absolute path of the configuration file can still be obtained by using the device provided by the embodiment of the present invention, and then, a process in a running state can be uniquely determined based on the absolute paths of the executable file and the configuration file of the process. In other words, the device provided by the embodiment of the present invention can realize accurate identification of the process, and then can realize accurate control of the process. In summary, it can be seen that the device provided by the embodiment of the present invention can solve the problem that the prior art cannot realize accurate identification and control of the process.
[0132] and Figure 1 Corresponding to the embodiment shown, the embodiment of the present invention further provides an electronic device, see Figure 4 , including a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404;
[0133] Memory 403, used for storing computer programs;
[0134] The processor 401 is used to implement any method step of the identification process in the above embodiments when executing the program stored in the memory.
[0135] In the process start instruction of the process to be identified, when the paths of the executable file and the configuration file are both relative paths, the absolute path of the configuration file can still be obtained by using the electronic device provided by the embodiment of the present invention, and then, a process in a running state can be uniquely determined based on the absolute paths of the executable file and the configuration file of the process. In other words, the electronic device provided by the embodiment of the present invention can realize accurate identification of the process, and then can realize accurate control of the process. In summary, the electronic device provided by the embodiment of the present invention can solve the problem that the prior art cannot realize accurate identification and control of the process.
[0136] and Figure 1Corresponding to the embodiment shown, an embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method steps of any process identification in the above embodiments are implemented.
[0137] In the process startup instruction of the process to be identified, when the paths of the executable file and the configuration file are both relative paths, the absolute path of the configuration file can still be obtained by using the storage medium provided by the embodiment of the present invention, and then, a process in a running state can be uniquely determined based on the absolute paths of the executable file and the configuration file of the process. In other words, the storage medium provided by the embodiment of the present invention can realize accurate identification of the process, and then can realize accurate control of the process. In summary, the storage medium provided by the embodiment of the present invention can solve the problem that the prior art cannot realize accurate identification and control of the process.
[0138] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.
[0139] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0140] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0141] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0142] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for process identification, characterized in that: Applied to a virtual machine or hardware server, it includes the following steps: Respectively receiving a process query instruction and an instruction for receiving an instruction for obtaining a process start instruction; wherein the process start instruction is an instruction input when starting a process; According to the process query instruction, a process in the running state is identified as a process to be identified, and identification information of the process to be identified is obtained; According to the instruction for obtaining a process start instruction, obtain a process start instruction of the process to be identified; wherein the process start instruction of the process to be identified includes: a start instruction of an executable file corresponding to the process to be identified, and a start instruction of a configuration file corresponding to the process to be identified; the start instruction of the executable file includes a path of the executable file; the start instruction of the configuration file includes a path of the configuration file; Obtaining the paths of the executable file and configuration file corresponding to the process to be identified from the process startup instruction of the process to be identified; When the paths of the executable file and the configuration file obtained from the process startup instruction of the process to be identified are both relative paths, obtaining the absolute path of the executable file corresponding to the process to be identified from the virtual file system according to the identification information of the process to be identified; Matching the absolute path of the executable file corresponding to the process to be identified with the relative path of the executable file corresponding to the process to be identified, and determining the current directory of the relative path of the executable file; Determine the parent directory of the relative path of the executable file according to the current directory of the relative path of the executable file; Determine the absolute path of the configuration file corresponding to the process to be identified according to the upper-level directory of the relative path of the executable file; The process to be identified is identified according to the absolute paths of the executable file and the configuration file corresponding to the process to be identified.
2. The method according to claim 1, characterized in that: The method further comprises: When the paths of the executable file and the configuration file in the process startup instruction of the process to be identified are absolute paths, the absolute paths of the executable file and the configuration file are obtained, and the process to be identified is identified according to the absolute paths of the executable file and the configuration file.
3. The method according to claim 1, characterized in that The steps of respectively receiving a process query instruction and receiving an instruction for obtaining a process start instruction include: Receive the process query command and the nginx process startup command respectively.
4. The method according to claim 3, characterized in that The step of identifying a process in a running state as a process to be identified according to the process query instruction and obtaining identification information of the process to be identified includes: According to the process query instruction, the nginx process in the running state is confirmed as the process to be identified, and the identification information of the process to be identified is obtained.
5. The method according to claim 1, characterized in that Before the step of acquiring the process startup instruction of the process to be identified according to the instruction of acquiring the process startup instruction, the step further includes: Receive a process start instruction issued by a user, start a corresponding process according to the process start instruction, and save the process start instruction.
6. A process identification device, characterized in that: The device comprises: An instruction receiving module, used to receive a process query instruction and an instruction to obtain a process start instruction respectively; wherein the process start instruction is an instruction input when starting a process; A confirmation module, configured to confirm a process in a running state in itself as a process to be identified according to the process query instruction, and obtain identification information of the process to be identified; An instruction acquisition module, used to acquire the process startup instruction of the process to be identified according to the instruction for acquiring the process startup instruction; wherein the process startup instruction of the process to be identified includes: a startup instruction of an executable file corresponding to the process to be identified, and a startup instruction of a configuration file corresponding to the process to be identified; the startup instruction of the executable file includes a path of the executable file; the startup instruction of the configuration file includes a path of the configuration file; A path acquisition module, used to acquire the path of the executable file and configuration file corresponding to the process to be identified from the process startup instruction of the process to be identified; an acquisition module, configured to acquire, from a virtual file system, an absolute path of the executable file corresponding to the process to be identified, according to the identification information of the process to be identified, when the paths of the executable file and the configuration file obtained from the process startup instruction of the process to be identified are both relative paths; A matching module, used for matching the absolute path of the executable file corresponding to the process to be identified with the relative path of the executable file corresponding to the process to be identified, and determining the current directory of the relative path of the executable file; A first determining module, used to determine the upper directory of the relative path of the executable file according to the current directory of the relative path of the executable file; A second determination module is used to determine the absolute path of the configuration file corresponding to the process to be identified according to the upper directory of the relative path of the executable file; The identification module is used to identify the process to be identified according to the absolute paths of the executable file and configuration file corresponding to the process to be identified.
7. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method steps described in any one of claims 1-5 when executing the program stored in the memory.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Method, device and equipment for managing and controlling processes in container and readable storage medium
CN114237924A
Web path intelligent searching method and device
CN118171268A
