Application deployment method and device, computer equipment, storage medium and program product
By integrating an execution engine into the development project of a compiled programming language, compiling the application source code of the interpreted programming language into bytecode and packaging it into an executable file, the problems of low operating efficiency and high deployment complexity of interpreted programming languages are solved, and the effect of simplifying deployment and improving operating efficiency is achieved.
Patent Information
- Application Number
- CN202410494001.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-23
- Publication Date
- 2025-10-24
AI Technical Summary
Applications written in interpreted programming languages need to rely on an interpreter to run, which has low operating efficiency. In addition, the interpreter and dependent libraries need to be installed in advance during deployment, resulting in high deployment complexity.
Integrate a compiled execution engine into the development project of a compiled programming language, use this engine to compile the application source code of the interpreted programming language into bytecode, and package it with the development project of the compiled programming language into a target executable file, which is executed directly on the target machine.
It simplifies the application deployment process, reduces deployment complexity, and improves operational efficiency and security.
Smart Images

Figure CN120832152A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to an application deployment method and device, computer equipment, computer readable storage medium and computer program product. BACKGROUND
[0002] For an application program written by a compiled programming language, before the application program runs, a source program needs to be compiled into machine code by a compiler, that is, an executable program is generated, and when the application program is run later, it does not need to be compiled again. Because the compilation is only done once, the application program of the compiled programming language can run independently without the language environment and has high execution efficiency.
[0003] For an application program written by an interpreted programming language, it is converted while being executed, and the programs needed are converted. No executable program is generated, but a conversion tool, that is, an interpreter, is needed during conversion. Therefore, the application program of the interpreted programming language is first translated into intermediate code, and then the interpreter runs the intermediate code. The application program is translated into machine code during running, one sentence is translated and then executed, and the process is repeated until the end. That is, at present, the application program written by the interpreted programming language needs to rely on the interpreter to run, and the running efficiency is relatively low. In addition, when deploying such an application program to a target machine, the interpreter, dependent library and other running environments need to be installed in advance, and the deployment complexity is high. SUMMARY
[0004] Therefore, it is necessary to provide an application deployment method, device, computer equipment, computer readable storage medium and computer program product to solve the above technical problems. The method can simplify the deployment process of the application program written by the interpreted programming language, improve the portability of the application program, and improve the running efficiency.
[0005] In a first aspect, the present application provides an application deployment method, comprising:
[0006] In a development project based on a first programming language, a compiled execution engine is integrated, the execution engine being used to execute source code based on a second programming language, the first programming language being a compiled programming language, and the second programming language being an interpreted programming language;
[0007] After the execution engine is initialized in the development project, the application source code based on the second programming language is compiled into bytecode by the execution engine, and a bytecode file corresponding to the application source code is obtained;
[0008] The development project based on the first programming language is compiled into an executable file.
[0009] packaging the executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code and the executable file corresponding to the development project into a target executable file;
[0010] deploying the target executable file to a target machine, so that after the target executable file is loaded on the target machine, the compiled execution engine is invoked to reconstruct and execute the business logic corresponding to the application source code from the bytecode file based on the executable file corresponding to the development project, and the reconstructed business logic is implemented based on the first programming language.
[0011] In a second aspect, the present application further provides an application deployment apparatus, comprising:
[0012] an integration module configured to integrate a compiled execution engine in a development project based on a first programming language, the execution engine being configured to execute source code based on a second programming language, the first programming language being a compiled programming language and the second programming language being an interpreted programming language;
[0013] a compilation module configured to compile, by the execution engine, application source code based on a second programming language into bytecode to obtain a bytecode file corresponding to the application source code after the execution engine is initialized in the development project;
[0014] a packaging module configured to compile a development project based on a first programming language into an executable file, and package an executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code and the executable file corresponding to the development project into a target executable file;
[0015] a deployment module configured to deploy the target executable file to a target machine, so that after the target executable file is loaded on the target machine, the compiled execution engine is invoked to reconstruct and execute the business logic corresponding to the application source code from the bytecode file based on the executable file corresponding to the development project, and the reconstructed business logic is implemented based on the first programming language.
[0016] In one embodiment, the integration module is configured to precompile the execution engine into an executable file, the execution engine being configured to execute source code based on a second programming language, determine a binding library corresponding to the execution engine, the binding library providing a programming interface for interaction between the execution engine and the first programming language, and add the binding library as a dependency to the development project based on the first programming language.
[0017] In one embodiment, the compiling module is configured to invoke the execution engine to create a handle scope instance of a sandbox, create a persistent context object in the handle scope instance, enter the created context object to create a context object scope, and compile a string obtained by converting the application source code based on the second programming language into bytecode into a bytecode file corresponding to the application source code in the context object scope.
[0018] In one embodiment, the packaging module is configured to link the compiled execution engine with a dependent library in the development project for invoking the execution engine, package an executable file corresponding to the compiled execution engine and an executable file corresponding to the development project into one executable file, and generate a target executable file of the application source code based on the one executable file and the bytecode file corresponding to the application source code.
[0019] In one embodiment, the deployment module is configured to invoke the compiled execution engine to obtain bytecode from the bytecode file based on the executable file corresponding to the development project, convert the bytecode into a cache data object suitable for the execution engine, and invoke a script compiling function in the compiled execution engine to reconstruct the business logic corresponding to the application source code from the cache data object through the script compiling function.
[0020] In one embodiment, the deployment module is configured to invoke a script running function in the compiled execution engine to execute the business logic corresponding to the application source code when the reconstruction is successful, and display web page content based on an execution result.
[0021] In one embodiment, the deployment module is configured to invoke the compiled execution engine to create a handle scope instance of a sandbox, create a persistent context object in the handle scope instance, enter the created context object to create a context object scope, generate metadata based on the bytecode in the context object scope, generate script source code based on the metadata, and reconstruct the business logic corresponding to the application source code from the cache data object and the script source code through the script compiling function.
[0022] In one embodiment, the application deployment apparatus further comprises an event loop simulation module, configured to invoke an asynchronous program runtime library based on the first programming language in the development project; invoke a handle scope instance of the sandbox created by the compiled execution engine; create a persistent context object in the handle scope instance; enter the created context object, and create a context object scope; in the context object scope, enter an event loop based on the first programming language, and in the event loop, dispatch and execute asynchronous tasks based on the second programming language through the asynchronous program runtime library.
[0023] In one embodiment, the application deployment apparatus further comprises a global object simulation module, configured to create a persistent context object in a handle scope instance of the sandbox; enter the created context object, and create a context object scope; in the context object scope, define a simulated global object based on the first programming language, the simulated global object being used to simulate a global object provided in a running environment of the first programming language, and the simulated global object being used to create a global variable or a global function in the development project based on the first programming language; define a simulated process object based on the first programming language, the simulated process object being used to simulate a process object provided in the running environment of the first programming language, and the simulated process object being used to create a process object in the development project based on the first programming language.
[0024] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, the memory storing a computer program, and the processor implementing the following steps when executing the computer program:
[0025] In the development project based on the first programming language, a compiled execution engine is integrated, the execution engine being used to execute source code based on the second programming language, the first programming language being a compiled programming language, and the second programming language being an interpreted programming language;
[0026] After the execution engine is initialized in the development project, the application source code based on the second programming language is compiled into bytecode through the execution engine, so as to obtain a bytecode file corresponding to the application source code;
[0027] The development project based on the first programming language is compiled into an executable file;
[0028] The executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code, and the executable file corresponding to the development project are packaged into a target executable file;
[0029] deploy the target executable file to a target machine, so that after the target executable file is loaded on the target machine, the compiled execution engine is invoked to reconstruct and execute the business logic corresponding to the application source code from the bytecode file based on the executable file corresponding to the development project, and the reconstructed business logic is implemented based on the first programming language.
[0030] In a fourth aspect, the present application further provides a computer readable storage medium, which has a computer program stored thereon, and the computer program is executed by a processor to implement the following steps:
[0031] In a development project based on a first programming language, a compiled execution engine is integrated, the execution engine is used to execute source code based on a second programming language, the first programming language is a compiled programming language, and the second programming language is an interpreted programming language.
[0032] After the execution engine is initialized in the development project, the application source code based on the second programming language is compiled into bytecode by the execution engine, so that a bytecode file corresponding to the application source code is obtained.
[0033] The development project based on the first programming language is compiled into an executable file.
[0034] The executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code, and the executable file corresponding to the development project are packaged into a target executable file.
[0035] The target executable file is deployed to a target machine, so that after the target executable file is loaded on the target machine, the compiled execution engine is invoked to reconstruct and execute the business logic corresponding to the application source code from the bytecode file based on the executable file corresponding to the development project, and the reconstructed business logic is implemented based on the first programming language.
[0036] In a fifth aspect, the present application further provides a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the following steps:
[0037] In a development project based on a first programming language, a compiled execution engine is integrated, the execution engine is used to execute source code based on a second programming language, the first programming language is a compiled programming language, and the second programming language is an interpreted programming language.
[0038] After the execution engine is initialized in the development project, the application source code based on the second programming language is compiled into bytecode by the execution engine, so that a bytecode file corresponding to the application source code is obtained.
[0039] compile the development project based on the first programming language into an executable file;
[0040] pack the executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code and the executable file corresponding to the development project into a target executable file;
[0041] deploy the target executable file to a target machine, so that after the target machine loads the target executable file, based on the executable file corresponding to the development project, the compiled execution engine is invoked to reconstruct and execute the business logic corresponding to the application source code from the bytecode file, and the reconstructed business logic is implemented based on the first programming language.
[0042] The application deployment method, device, computer device, computer readable storage medium and computer program product can integrate a compiled execution engine in a development project based on a first programming language, that is, a compiled programming language, the execution engine is used to execute source code based on a second programming language, that is, an interpreted programming language, that is, the execution engine can provide a running environment for the interpreted programming language, and then after the execution engine is initialized in the development project, the application source code based on the second programming language can be compiled into bytecode by the execution engine to obtain a bytecode file corresponding to the application source code. After the development project based on the first programming language is compiled into an executable file, the executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code and the executable file corresponding to the development project are packed into a target executable file. The target executable file is deployed to a target machine, so that after the target machine loads the target executable file, based on the executable file corresponding to the development project, the compiled execution engine is invoked to reconstruct and execute the business logic corresponding to the application source code from the bytecode file, and the reconstructed business logic is implemented based on the first programming language.
[0043] The application deployment method can compile all codes and pack them into a target executable file through the above process, so that the target executable file only needs to be deployed to a target machine for running. Compared with deploying a complete application program based on the second programming language, that is, the interpreted programming language, which needs to additionally deploy dependent libraries and configure a running environment, the above application deployment process is very simple. Moreover, since the codes have been compiled into executable files, there is no need to install dependent libraries or other running environments on the target machine, which greatly reduces the complexity of application deployment. In addition, since the codes have been compiled and packed into executable files, the security of the application can be ensured, and the application source code can run faster than the application source code that is executed while being interpreted. BRIEF DESCRIPTION OF DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the following will briefly introduce the drawings needed to be used in the description of the embodiments of the present application or the related art. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other related drawings can also be obtained based on these drawings without creative labor.
[0045] Figure 1 a schematic diagram of application programs based on different programming languages;
[0046] Figure 2 a code schematic diagram of embedding an execution engine of a second programming language into a development project based on a first programming language in an embodiment;
[0047] Figure 3 an application environment diagram of the application deployment method in an embodiment;
[0048] Figure 4 a flowchart of the application deployment method in an embodiment;
[0049] Figure 5 a code schematic diagram of binding and initializing a V8 engine in an embodiment;
[0050] Figure 6 a code schematic diagram of obtaining bytecode in an embodiment;
[0051] Figure 7 a code schematic diagram of linking an execution engine and a dependent library in an embodiment;
[0052] Figure 8 a code schematic diagram of compiling a program based on a first programming language in an embodiment;
[0053] Figure 9 a flowchart of reconstructing and executing business logic corresponding to application source code from a bytecode file in an embodiment;
[0054] Figure 10 a code schematic diagram of reconstructing and executing application source code in an embodiment;
[0055] Figure 11 a code schematic diagram of simulating an event loop capability in a development project based on a first programming language in an embodiment;
[0056] Figure 12 a code schematic diagram of simulating a global object in a development project based on a first programming language in an embodiment;
[0057] Figure 13 a structural block diagram of an application deployment apparatus in an embodiment;
[0058] Figure 14 Fig. 1 is a diagram of the internal structure of a computer device according to an embodiment of the present application.
[0059] Figure 15 Fig. 2 is a diagram of the internal structure of a computer device according to another embodiment of the present application. DETAILED DESCRIPTION
[0060] In order to make the objects, technical solutions and advantages of the present application clearer, the present application will be described in further detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application.
[0061] First, some terms related to the embodiments of the present application will be described.
[0062] Bytecode (also known as byte code) is intermediate code between source code and machine code. It is a low-level code that is the result of compiling source code written in a high-level language. It is processed by a virtual machine such as a Java Virtual Machine (JVM). Bytecode is a non-executable code that can be understood by a machine after it is translated into machine code by an interpreter.
[0063] Machine code (also known as machine code) is a set of instructions that can be directly understood and executed by a computer, which is processed by a central processing unit. Machine code is in binary format, which is completely different from bytecode and source code. Machine code is obtained after compilation or interpretation, and machine code is executed very quickly.
[0064] V8 Engine: is an open source JavaScript engine, the main capability of V8 engine is to interpret and compile JavaScript source code and run.
[0065] Node.js is a server-side JavaScript runtime environment developed based on the V8 engine, which allows developers to write server-side code using JavaScript. Node.js provides a set of APIs that allow JavaScript code to access the underlying functionality of the operating system, such as file systems, networks, processes, etc. The characteristics of Node.js are high efficiency, light weight, scalability, and are suitable for developing high-concurrency, real-time, and scalable network applications.
[0066] Rust is a general-purpose compiled programming language that follows the design guidelines of "safety, concurrency, and utility", and supports functional, concurrent, procedural, and object-oriented programming styles.
[0067] A compiled programming language: for an application program written by a compiled programming language, before the application program runs, the source program needs to be compiled into machine code by a compiler, that is, to generate an executable program, and when running this application program, it does not need to be compiled again. Because the compilation is done only once, there is no need for compilation at runtime, so the application program of the compiled programming language has high execution efficiency and can run independently of the language environment. After compilation, if modification is needed, the entire module needs to be recompiled. When compiling, machine code is generated according to the corresponding running environment, and porting between different operating systems will have problems, and different executable files need to be compiled according to the operating system environment. For example, C, C++, Rust, etc.
[0068] An interpreted programming language: for an application program written by an interpreted programming language, it is converted while being executed, and the program needs to be converted, and no executable program is generated, but a conversion tool, that is, an interpreter, is needed during conversion. Therefore, the application program of the interpreted programming language is not directly translated into machine code, but first translated into intermediate code, and then interpreted and run by the interpreter. The application program is translated into machine code during running, one sentence is translated, and then one sentence is executed until the end. That is, in the related art, the application program written by the interpreted programming language needs to rely on the interpreter to run, and the running efficiency is relatively low, and in addition, when deploying such an application program to a target machine, the interpreter, dependent library, and other running environments need to be installed in advance, and the deployment complexity is high. For example, JavaScript, etc.
[0069] To solve the above problems, the embodiment of the present application can compile and package all the codes into a target executable file, so that only the target executable file needs to be deployed to the target machine for running. Compared with deploying a complete application program based on a second programming language, that is, an interpreted programming language, which needs to additionally deploy dependent libraries and configure the running environment, the above application deployment process is very simple, and since the code has been compiled into an executable file, there is no need to install dependent libraries or other running environments on the target machine, which greatly reduces the complexity of application deployment. In addition, since the code has been compiled and packaged into an executable file, the security of the application can be guaranteed, and the application source code can run faster than the application source code running by interpretation.
[0070] As shown in Figure 1 Fig. 1 is a schematic diagram of an application program based on different programming languages in an embodiment. Referring to Figure 1, the application program based on the first programming language is usually run in the running environment of the first programming language, for example, the Rust code is run in the Rust environment. In the running environment of the second programming language, the application program based on the second programming language is run, for example, the JavaScript code is run in the Node.js environment. In order to improve the deployment efficiency and running rate of the application program based on the second programming language, it is necessary to package the application program based on the second programming language into a binary executable file, such as Figure 2 In the embodiments of the present application, the execution engine of the second programming language is used to generate an executable file of the application program based on the second programming language in the development project based on the first programming language, that is, the execution engine of the second programming language is embedded into the development project based on the first programming language, and the execution engine is used to compile and execute the application program based on the second programming language in the development project.
[0071] The application deployment method provided by the embodiments of the present application can be applied to an application environment as shown in Figure 3 The terminal 102 communicates with the server 104 through the network. The data storage system can store the data required to be processed by the server 104. The data storage system can be integrated on the server 104, or placed on the cloud or other network servers. In one embodiment, the terminal 102 integrates a compiled execution engine in a development project based on a first programming language, the execution engine is used to execute source code based on a second programming language, the first programming language is a compiled programming language, and the second programming language is an interpreted programming language; after initializing the execution engine in the development project, the execution engine is used to compile the application source code based on the second programming language into bytecode to obtain a bytecode file corresponding to the application source code; the development project based on the first programming language is compiled into an executable file; the compiled executable file corresponding to the execution engine, the bytecode file corresponding to the application source code, and the executable file corresponding to the development project are packaged into a target executable file; and the target executable file is deployed to the server 104, so that after the target executable file is loaded on the server 104, the compiled execution engine is called based on the executable file corresponding to the development project to reconstruct and execute the business logic corresponding to the application source code from the bytecode file, and the reconstructed business logic is implemented based on the first programming language.
[0072] The terminal 102 can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, Internet of Things devices, and portable wearable devices. The Internet of Things device can be a smart speaker, a smart television, a smart air conditioner, a smart vehicle-mounted device, a projection device, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc. The server 104 can be a standalone physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0073] In an exemplary embodiment, as shown in Figure 4 , a method for application deployment is provided, which is applied to a computer device (the terminal 102 or the server 104) in Figure 3 and includes the following steps 402 to 410. Wherein:
[0074] Step 402, in a development project based on a first programming language, a compiled execution engine is integrated, the execution engine is used to execute source code based on a second programming language, the first programming language is a compiled programming language, and the second programming language is an interpreted programming language.
[0075] In the embodiment of the application, the first programming language is a compiled programming language, and the second programming language is an interpreted programming language. In order to solve the problem that an application program written in the interpreted programming language needs to rely on an interpreter for running and the running efficiency is relatively low, in addition, when deploying such an application program to a target machine, an interpreter, a dependent library, and other running environments need to be installed in advance, and the deployment complexity is high, a compiled execution engine is integrated in the development project based on the first programming language, the execution engine is used to execute source code based on the second programming language, and thus the execution engine of the second programming language is embedded into the development project based on the first programming language. Optionally, the first programming language can be, for example, Rust, the second programming language can be, for example, JavaScript, and the execution engine used to execute the source code based on the second programming language can be, for example, the Chrome V8 engine. In this way, when all the codes are compiled and packaged into a target executable file, the packaging tool such as webpack (a module packer that can package all the modules according to the dependency relationship between each module file) can not be relied on, but the V8 engine is directly interacted with, so as to realize a more efficient and flexible packaging process.
[0076] It is a relatively complex task to integrate an execution engine for a second programming language in a development project based on a first programming language, because the two are based on different programming languages. In a development project based on a first programming language, integrating a compiled execution engine includes the process of binding the dependent library of the callable V8 engine in the development project based on the first programming language and the process of initializing the V8 engine.
[0077] In an embodiment, in a development project based on a first programming language, integrating a compiled execution engine includes: pre-compiling the execution engine into an executable file, the execution engine being used to execute source code based on a second programming language; determining a binding library corresponding to the execution engine, the binding library providing a programming interface for interacting with the execution engine based on the first programming language; and adding the binding library as a dependency to the development project based on the first programming language.
[0078] Specifically, the computer device can download the source code of the execution engine, compile the source code of the execution engine to generate a library file suitable for the platform on which the development project based on the first programming language is located, i.e., an executable file corresponding to the execution engine, and then add the compiled library file to the development project based on the first programming language and use an external function interface mechanism in the first programming language to call the execution engine.
[0079] When the computer device adds the compiled library file to the development project based on the first programming language, it can determine a binding library corresponding to the execution engine in the platform on which the development project based on the first programming language is located, the binding library providing a programming interface for interacting with the execution engine based on the first programming language, and adding the binding library as a dependency to the development project based on the first programming language, thus achieving the addition of the compiled library file to the development project based on the first programming language. Subsequently, the binding library can be used to directly interact with the execution engine.
[0080] For example, the computer device can use rusty_v8 of Rust, which is a library that provides relevant programming interfaces for the V8 engine. This library provides an interface for Rust programs to call the V8 engine and allows the creation and operation of V8 objects in Rust programs. Figure 5 As shown in FIG. 1, it is a schematic diagram of binding and initializing the V8 engine. In the code shown in Figure 5 As shown in FIG. 2, it is a schematic diagram of how to use rusty_v8 to initialize the V8 engine in a Rust program and execute a piece of JavaScript code. Referring to Figure 5 , first, the V8 engine is initialized in the development project through configuration and startup parameters, and then a sandbox is created by calling the interface of the V8 engine, which is an independent running environment for JavaScript code. A piece of JavaScript code can be executed in this sandbox.
[0081] At step 404, after initializing the execution engine in the development project, the computer device compiles the application source code based on the second programming language into bytecode through the execution engine to obtain a bytecode file corresponding to the application source code.
[0082] The process of the execution engine executing the application source code based on the second programming language includes three stages of parsing, compiling, and running. In the parsing stage, the application source code based on the second programming language is first converted into an abstract syntax tree by a parser. In the compiling stage, the execution engine converts the abstract syntax tree into bytecode, which can be efficiently executed on a virtual machine of the execution engine. In the running stage, the execution engine converts the bytecode into machine code and executes it. This step is usually dynamically completed at runtime, and is optimized according to the actual running situation and environment information of the code. It should be noted that not all application source codes based on the second programming language are compiled into bytecode. For some simple and directly executable codes, the execution engine can directly generate machine code and skip the generation stage of bytecode.
[0083] After the computer device initializes the execution engine in the development project, the computer device compiles the application source code based on the second programming language into bytecode through the execution engine to obtain a bytecode file corresponding to the application source code. When the computer device compiles the application source code based on the second programming language into bytecode through the execution engine, the computer device can call the execution engine to implement it according to the dependency library. Therefore, the above process is implemented by the called execution engine, and the implementation details do not need to be concerned, the code is lightweight, and the bytecode file can be efficiently generated.
[0084] In one embodiment, the application source code based on the second programming language is compiled into bytecode through the execution engine to obtain a bytecode file corresponding to the application source code, including: calling the execution engine to create a sandbox and a handle scope instance of the sandbox; creating a persistent context object in the handle scope instance; entering the created context object to create a context object scope; in the context object scope, after converting the application source code based on the second programming language into a string, the string is compiled into bytecode to obtain a bytecode file corresponding to the application source code.
[0085] That is, after initializing the execution engine based on the second programming language in the development project based on the first programming language, the execution engine can be called to create an isolate, which is an isolated instance in the execution engine and represents an independent execution environment of the application source code based on the second programming language. Then, a HandleScope is created, which is used to manage the life cycle of JavaScript objects. Within the HandleScope, a Context is created, which can explicitly separate the application source code based on the second programming language from each other and run in the same execution engine without interfering with each other. Then, a ContextScope is created, and the application source code based on the second programming language is compiled within the ContextScope to obtain the bytecode file corresponding to the application source code.
[0086] As shown in Figure 6 , it is a schematic diagram of obtaining bytecode in an embodiment. Referring to Figure 6 , after the application source code based on the second programming language is compiled within the ContextScope to obtain the bytecode file corresponding to the application source code, the compiled bytecode can be run to obtain a running result, the running result is converted into a Rust string and printed, and finally the ContextScope is explicitly discarded and the execution engine is closed to ensure that all resources are properly released.
[0087] Step 406, compiling the development project based on the first programming language into an executable file.
[0088] The development project based on the first programming language further includes reconstruction code, which is used to call the compiled execution engine to reconstruct and execute the business logic corresponding to the application source code from the bytecode file. Specifically, after obtaining the bytecode file corresponding to the application source code, in order for the server to successfully implement the business logic corresponding to the application source code, the computer device also needs to implement the reconstruction code in the development project, so that after all files are packaged, the server can implement the reconstruction of the business logic corresponding to the application source code by executing the reconstruction code. Then, the computer device can compile the development project based on the first programming language into an executable file.
[0089] Step 408, packaging the executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code, and the executable file corresponding to the development project into a target executable file.
[0090] In order to be able to directly implement the business logic corresponding to the application source code on the target machine, after obtaining the executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code, and the executable file corresponding to the development project, the computer device packages the executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code, and the executable file corresponding to the development project to obtain a target executable file. The target executable file can be directly copied to the target machine, and the target executable file is run on the target machine to implement the server-side deployment of the application source code based on the first programming language. For example, the computer device compiles the development project written based on Rust into an executable file, that is, uses a Rust compiler (such as rustc) to compile Rust code into an executable file. It can be understood that in this process, the computer device needs to package the generated executable file together with the dependencies of the development project so as to be deployed to other machines.
[0091] In one embodiment, packaging the executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code, and the executable file corresponding to the development project into a target executable file includes: after linking the compiled execution engine with a dependent library in the development project for calling the execution engine, packaging the executable file corresponding to the compiled execution engine and the executable file corresponding to the development project into one executable file; and generating the target executable file about the application source code according to one executable file and the bytecode file corresponding to the application source code.
[0092] In this embodiment, in order to reduce the trouble of recompiling and packaging all the codes after modifying the application source code, the compiled execution engine can be linked with a dependent library in the development project for calling the execution engine, and then the executable file corresponding to the compiled execution engine and the executable file corresponding to the development project can be packaged into one executable file. Then, the one executable file and the bytecode file corresponding to the application source code are packaged to generate a target executable file. In this way, in the case that the application source code is modified, only the executable file generated by recompiling the application source code needs to be packaged with the bytecode file corresponding to the modified application source code to generate the target executable file again.
[0093] For example, after determining the binding library in Rust for calling the V8 engine and the executable file corresponding to the V8 engine, the computer device can link the binding library and the V8 engine together, as shown in Figure 7 The -l option of g++ or clang++ is used to specify the library to be linked by the V8 engine. Then, the computer device compiles the Rust development project into an executable file, as shown in Figure 8As shown, cargo is used to compile the Rust code into an executable file. Finally, the computer device packs the executable file corresponding to the V8 engine and the executable file compiled from the Rust development project, and packs the bytecode file corresponding to the JavaScript code to obtain the final target executable file.
[0094] At step 410, the target executable file is deployed to the target machine, and after the target executable file is loaded on the target machine, the compiled execution engine is invoked to reconstruct and execute the business logic corresponding to the application source code from the bytecode file based on the executable file corresponding to the development project, and the reconstructed business logic is implemented based on the first programming language.
[0095] After the target executable file is deployed to the target machine, the target machine loads and runs the target executable file. On the target machine, the compiled execution engine is invoked to reconstruct and execute the business logic corresponding to the application source code from the bytecode file based on the executable file corresponding to the development project, that is, the bytecode file obtained by previous compilation is converted into a cache data object that can be used by the execution engine, which contains sufficient information for the execution engine to use in subsequent compilation, and the business logic based on the first programming language can be reconstructed according to the object.
[0096] In one embodiment, as shown in Figure 9 The compiled execution engine is invoked to reconstruct and execute the business logic corresponding to the application source code from the bytecode file based on the executable file corresponding to the development project, including:
[0097] At step 902, the compiled execution engine is invoked to obtain bytecode from the bytecode file based on the executable file corresponding to the development project, and the bytecode is converted into a cache data object suitable for the execution engine;
[0098] At step 904, a script compilation function in the compiled execution engine is invoked to reconstruct the business logic corresponding to the application source code from the cache data object through the script compilation function.
[0099] For example, as shown in Figure 10As shown, on the target machine, the previously compiled bytecode can be converted into a CachedData object that can be used by V8 based on the executable file corresponding to the development project, and the v8::script_compiler::ScriptCompiler::compile function and the CompileOptions::ConsumeCodeCache option are used to attempt to reconstruct the code from the bytecode. The v8::script_compiler::ScriptCompiler::compile function is a function in the V8 engine for compiling JavaScript code, and the CodeCache is an area for storing just-in-time compiled code.
[0100] In one embodiment, the method further comprises: when the reconstruction is successful, calling a script running function in the compiled execution engine to execute the business logic corresponding to the application source code to obtain an execution result; and displaying web page content according to the execution result.
[0101] Reference Figure 10 If the reconstruction is successful, a reconstructed business logic, referred to as Some(script), is obtained, otherwise None is obtained. If the reconstruction is successful, the script running function script.run(scope) is used to execute it, and the execution result is an Option <v8::value>If there is a return value after execution, it can be converted to a string and printed out. If there is no return value after execution or execution fails, the corresponding message is printed out.
[0102] In one embodiment, the method further comprises: calling the compiled execution engine to create a handle scope instance of a sandbox; creating a persistent context object within the handle scope instance; entering the created context object to create a context object scope; within the context object scope, generating metadata according to the bytecode, and generating script source code according to the metadata; and reconstructing the business logic corresponding to the application source code from the cached data object by the script compilation function, including: reconstructing the business logic corresponding to the application source code from the cached data object and the script source code by the script compilation function.
[0103] Referring to Figure 10 To reconstruct the business logic corresponding to the application source code, a new scope and a context are first created, and then the scope of the context is entered. The bytecode obtained by previous compilation is converted into a CachedData object that can be used by the V8 engine using ::script_compiler::CachedData::new(bytecode). An empty metadata source and script source code are also created, and the business logic corresponding to the application source code is reconstructed from the cached data object and the script source code using the v8::script_compiler::ScriptCompiler::compile function and the CompileOptions::ConsumeCodeCache option.
[0104] In the application deployment method described above, in a development project based on a first programming language, i.e., a compiled programming language, a compiled execution engine is integrated, which is used to execute source code based on a second programming language, i.e., an interpreted programming language. That is, the execution engine can provide a running environment for the interpreted programming language. Then, after the execution engine is initialized in the development project, the execution engine can be used to compile the application source code based on the second programming language into bytecode to obtain a bytecode file corresponding to the application source code. After the development project based on the first programming language is compiled into an executable file, the executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code, and the executable file corresponding to the development project are packaged into a target executable file. The target executable file is deployed to a target machine. After the target executable file is loaded on the target machine, the business logic corresponding to the application source code is reconstructed and executed from the bytecode file by the compiled execution engine based on the executable file corresponding to the development project. The reconstructed business logic is implemented based on the first programming language.
[0105] Through the above process, all codes can be compiled and packaged into a target executable file. Then, you only need to deploy this target executable file to the target machine to run it. Compared with deploying a complete application based on a second programming language, that is, an interpreted programming language, which requires additional deployment of dependent libraries and configuration of the operating environment, the above application deployment process is very simple. Moreover, since the code has been compiled into an executable file, there is no need to install dependent libraries or other operating environments on the target machine, which greatly reduces the complexity of application deployment. In addition, since the code has been compiled and packaged into an executable file, the security of the application can be guaranteed, and it will run faster than the application source code that is interpreted and executed at the same time.
[0106] In an embodiment of the present application, the application source code is compiled into a bytecode file and deployed to a target machine. The target machine rebuilds and runs the reconstructed business logic independently of the original operating environment (such as Node.js). Although this process may not depend on the original operating environment, some tasks still depend on the specific interface functions provided by the operating environment. Therefore, the computer device can simulate the functions to be implemented by these required specific interface functions in the development project based on the first programming language.
[0107] In an exemplary embodiment, the method further includes: calling an asynchronous program runtime library based on a first programming language in a development project; calling a compiled execution engine to create a handle scope instance of a sandbox; creating a persistent context object within the handle scope instance; entering the created context object and creating a context object scope; within the context object scope, entering an event loop based on the first programming language, and scheduling an asynchronous task based on a second programming language through the asynchronous program runtime library within the event loop and executing the asynchronous task.
[0108] In this embodiment, Figure 11 The figure below shows a schematic diagram of simulating event loop capabilities in a development project based on a first programming language. This involves calling an asynchronous runtime library, such as Tokio, based on the first programming language. This then calls the compiled execution engine to create a handle scope instance and a global context for the sandbox isolate. This event loop then enters an event loop, where the asynchronous runtime library schedules and executes asynchronous tasks (JavaScript code) based on a second programming language. These asynchronous tasks might involve file reads and writes, network requests, and so on. By converting these operations into asynchronous tasks in Rust and scheduling them using Tokio's API, the event loop capabilities inherent to the runtime environment are achieved.
[0109] In one embodiment, the method further comprises: creating a persistent context object within the handle scope instance of the sandbox; entering the created context object, creating a context object scope; within the context object scope, defining a simulated global object based on the first programming language, the simulated global object being used to simulate a global object provided in a runtime environment of the first programming language, the simulated global object being used to create a global variable or a global function in the development project based on the first programming language; defining a simulated process object based on the first programming language, the simulated process object being used to simulate a process object provided in the runtime environment of the first programming language, the simulated process object being used to create a process object in the development project based on the first programming language.
[0110] For example, in Node.js, the global object is a proxy to the global scope, which provides access to all global variables and functions. The process object of Node.js provides information and methods related to the current Node.js process. In Rust, the behavior of this process can be simulated by creating a similar object. As shown in Figure 12 , a schematic diagram for simulating a global object in a development project based on the first programming language. Referring to Figure 12 , in this schematic diagram, it is shown how to create a process similar to the global object in the Node.js environment in Rust. In this way, JavaScript code that needs to rely on the global object to run in Rust can be implemented by calling the simulated global object, without affecting the normal operation of the code.
[0111] In one specific embodiment, the application deployment method comprises the following steps:
[0112] 1. Precompiling the execution engine into an executable file, the execution engine being used to execute source code based on a second programming language, the second programming language being an interpreted programming language;
[0113] 2. Determining a binding library corresponding to the execution engine, the binding library providing a programming interface for interaction between the first programming language and the execution engine, the first programming language being a compiled programming language;
[0114] 3. Adding the binding library as a dependency to the development project based on the first programming language, the execution engine being used to execute source code based on the second programming language;
[0115] 4. After initializing the execution engine in the development project, calling the execution engine to create a sandbox and a handle scope instance of the sandbox, creating a persistent context object within the handle scope instance, entering the created context object, creating a context object scope, and within the context object scope, converting the application source code based on the second programming language into a string, and compiling the string into bytecode to obtain a bytecode file corresponding to the application source code.
[0116] 5. Compiling the development project based on the first programming language into an executable file, linking the compiled execution engine with the dependent library in the development project for calling the execution engine, packing the executable file corresponding to the compiled execution engine and the executable file corresponding to the development project into one executable file, and generating the target executable file about the application source code according to the bytecode file corresponding to the one executable file and the application source code;
[0117] 6. Deploying the target executable file to the target machine, and after loading the target executable file on the target machine, calling the compiled execution engine to obtain bytecode from the bytecode file based on the executable file corresponding to the development project, converting the bytecode into a cache data object suitable for the execution engine; calling the compiled execution engine to create a handle scope instance of the sandbox, creating a persistent context object in the handle scope instance, entering the created context object, creating a context object scope, generating metadata according to the bytecode in the context object scope, generating script source code according to the metadata, calling a script compilation function in the compiled execution engine, reconstructing the business logic corresponding to the application source code from the cache data object through the script compilation function, and implementing the reconstructed business logic based on the first programming language;
[0118] 7. When the reconstruction is successful, calling a script running function in the compiled execution engine to execute the business logic corresponding to the application source code, obtaining an execution result, and displaying web page content according to the execution result;
[0119] 8. Calling an asynchronous program runtime library based on the first programming language in the development project, calling the compiled execution engine to create a handle scope instance of the sandbox, creating a persistent context object in the handle scope instance, entering the created context object, creating a context object scope, entering an event loop based on the first programming language in the context object scope, and scheduling and executing an asynchronous task based on the second programming language through the asynchronous program runtime library in the event loop.
[0120] Through the above process, all codes can be compiled and packed into one target executable file, and then the target executable file can be deployed to the target machine for running. Compared with deploying a complete application program based on the second programming language (i.e. an interpreted programming language) which requires additional deployment of dependent libraries and configuration of a running environment, the above application deployment process is very simple. Moreover, since the codes have been compiled into executable files, there is no need to install dependent libraries or other running environments on the target machine, which greatly reduces the complexity of application deployment. In addition, since the codes have been compiled and packed into executable files, the security of the application can be guaranteed, and the application can run faster than the application source code which is executed by being interpreted.
[0121] It should be understood that although the steps in the flowcharts involved in the above embodiments are shown in sequence according to the arrows, the steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, the execution of the steps is not strictly limited in sequence, and the steps can be executed in other orders. Moreover, at least some of the steps in the flowcharts involved in the above embodiments can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of the steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least part of other steps or steps or stages in other steps.
[0122] Based on the same inventive concept, the embodiments of the present application also provide an application deployment apparatus for implementing the above-mentioned application deployment method. The implementation scheme for solving the problem provided by the apparatus is similar to the implementation scheme described in the above method, so the specific limitations in one or more application deployment apparatus embodiments provided below can refer to the limitations of the application deployment method described above, which will not be repeated here.
[0123] In one exemplary embodiment, as shown in Figure 13 An application deployment apparatus 1300 is provided, comprising an integration module 1302, a compilation module 1304, a packaging module 1306, and a deployment module 1308, wherein:
[0124] The integration module 1302 is configured to integrate a compiled execution engine in a development project based on a first programming language, the execution engine being configured to execute source code based on a second programming language, the first programming language being a compiled programming language, and the second programming language being an interpreted programming language.
[0125] The compilation module 1304 is configured to compile the application source code based on the second programming language into bytecode through the execution engine after initializing the execution engine in the development project, to obtain a bytecode file corresponding to the application source code.
[0126] The packaging module 1306 is configured to compile the development project based on the first programming language into an executable file; package the executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code, and the executable file corresponding to the development project into a target executable file.
[0127] The deployment module 1308 is configured to deploy the target executable file to a target machine, so that after loading the target executable file on the target machine, the compiled execution engine is called based on the executable file corresponding to the development project to reconstruct and execute the business logic corresponding to the application source code from the bytecode file, and the reconstructed business logic is implemented based on the first programming language.
[0128] In one embodiment, the integration module 1302 is configured to pre-compile an execution engine for an executable file, the execution engine is configured to execute source code based on a second programming language; determine a binding library corresponding to the execution engine, the binding library provides a programming interface for interacting with the execution engine based on a first programming language; and add the binding library as a dependency to a development project based on the first programming language.
[0129] In one embodiment, the compiling module 1304 is configured to invoke the execution engine to create a handle scope instance of a sandbox; create a persistent context object within the handle scope instance; enter the created context object to create a context object scope; and convert the application source code based on the second programming language into a string, and compile the string into bytecode to obtain a bytecode file corresponding to the application source code within the context object scope.
[0130] In one embodiment, the packaging module 1306 is configured to link the compiled execution engine with a dependent library in the development project for invoking the execution engine, and then package an executable file corresponding to the compiled execution engine and an executable file corresponding to the development project into one executable file; and generate a target executable file for the application source code based on the one executable file and the bytecode file corresponding to the application source code.
[0131] In one embodiment, the deployment module 1308 is configured to invoke the compiled execution engine to obtain bytecode from the bytecode file and convert the bytecode into a cache data object suitable for the execution engine based on the executable file corresponding to the development project; and invoke a script compilation function in the compiled execution engine to reconstruct the business logic corresponding to the application source code from the cache data object through the script compilation function.
[0132] In one embodiment, the deployment module 1308 is configured to invoke a script running function in the compiled execution engine to execute the business logic corresponding to the application source code when the reconstruction is successful, and obtain an execution result; and display web page content based on the execution result.
[0133] In one embodiment, the deployment module 1308 is configured to invoke the compiled execution engine to create a handle scope instance of a sandbox; create a persistent context object within the handle scope instance; enter the created context object to create a context object scope; and generate metadata based on the bytecode within the context object scope, and generate script source code based on the metadata; and reconstruct the business logic corresponding to the application source code through the script compilation function based on the cache data object and the script source code.
[0134] In one embodiment, the application deployment apparatus 1300 further comprises an event loop simulation module, configured to invoke an asynchronous program runtime library based on the first programming language in the development project; invoke a handle scope instance of the compiled execution engine to create a sandbox; create a persistent context object within the handle scope instance; enter the created context object to create a context object scope; enter an event loop based on the first programming language within the context object scope, and schedule and execute an asynchronous task based on the second programming language within the event loop through the asynchronous program runtime library.
[0135] In one embodiment, the application deployment apparatus 1300 further comprises a global object simulation module, configured to create a persistent context object within the handle scope instance of the sandbox; enter the created context object to create a context object scope; define a simulation global object based on the first programming language within the context object scope, the simulation global object being used to simulate a global object provided in a running environment of the first programming language, and the simulation global object being used to create a global variable or a global function in the development project based on the first programming language; and define a simulation process object based on the first programming language, the simulation process object being used to simulate a process object provided in the running environment of the first programming language, and the simulation process object being used to create a process object in the development project based on the first programming language.
[0136] The application deployment apparatus 1300 described above, in a development project based on a first programming language, i.e., a compiled programming language, integrates a compiled execution engine, which is used to execute source code based on a second programming language, i.e., an interpreted programming language, i.e., the execution engine can provide a running environment for the interpreted programming language, and then, after the execution engine is initialized in the development project, the application source code based on the second programming language is compiled into bytecode through the execution engine to obtain a bytecode file corresponding to the application source code, the development project based on the first programming language is compiled into an executable file, the executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code, and the executable file corresponding to the development project are packaged into a target executable file, the target executable file is deployed to a target machine, and after the target executable file is loaded on the target machine, the compiled execution engine is invoked based on the executable file corresponding to the development project to reconstruct and execute the business logic corresponding to the application source code from the bytecode file, and the reconstructed business logic is implemented based on the first programming language.
[0137] The application deployment method can compile all the codes and package them into a target executable file through the above process. Then, the target executable file only needs to be deployed on the target machine to run. Compared with deploying a complete application based on a second programming language, i.e., an interpreted programming language, which needs to additionally deploy dependent libraries and configure a running environment, the above application deployment process is very simple. Moreover, since the codes have been compiled into an executable file, there is no need to install dependent libraries or other running environments on the target machine, which greatly reduces the complexity of application deployment. In addition, since the codes have been compiled and packaged into an executable file, the security of the application can be guaranteed, and the application source code can run faster than the application source code that is executed by interpretation.
[0138] The various modules in the application deployment apparatus 1300 can be implemented by software, hardware, and combinations thereof, in whole or in part. The various modules can be embedded in or independent of a processor in a computer device in hardware form, or stored in a memory in a computer device in software form, so as to be called and executed by a processor to perform the operations corresponding to the various modules.
[0139] In an exemplary embodiment, a computer device, which can be a server, is provided. An internal structure diagram of the computer device can be as shown in Figure 14 The computer device includes a processor, a memory, an input / output interface, and a communication interface. The processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is configured to exchange information between the processor and external devices. The communication interface of the computer device is configured to communicate with external terminals through a network connection. The computer program is executed by the processor to implement an application deployment method.
[0140] In an exemplary embodiment, a computer device, which can be a terminal, is provided. An internal structure diagram of the computer device can be as shown in Figure 15 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner. The wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, an application deployment method is implemented.
[0141] Those skilled in the art will understand that Figure 14 、 Figure 15 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0142] In an exemplary embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps of the above-mentioned application deployment method when executing the computer program.
[0143] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned application deployment method are implemented.
[0144] In one embodiment, a computer program product is provided, comprising a computer program, which implements the steps of the above-mentioned application deployment method when executed by a processor.
[0145] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0146] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. The non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. The volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, the RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., without being limited thereto.
[0147] The technical features of the above embodiments can be combined in any manner. To make the description concise, all possible combinations of the technical features in the above embodiments are not described, but as long as the combinations of the technical features do not exist contradictions, they should be considered as the scope of the present application.
[0148] The above-described embodiments are merely illustrative of several embodiments of the present application, and the description is relatively specific and detailed, but should not be understood as a limitation on the scope of the patent. It should be noted that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the scope of the present application. Therefore, the scope of protection of the present application should be subject to the appended claims.
Claims
1. An application deployment method characterized by comprising: The method comprises: integrating a compiled execution engine in a development project based on a first programming language, the execution engine being used to execute source code based on a second programming language, the first programming language being a compiled programming language, and the second programming language being an interpreted programming language; compiling, by the execution engine, application source code based on the second programming language into bytecode to obtain a bytecode file corresponding to the application source code after initializing the execution engine in the development project; compiling the development project based on the first programming language into an executable file; packing the executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code, and the executable file corresponding to the development project into a target executable file; deploying the target executable file to a target machine, so that after the target machine loads the target executable file, the compiled execution engine is invoked based on the executable file corresponding to the development project to reconstruct and execute business logic corresponding to the application source code from the bytecode file, and the reconstructed business logic is implemented based on the first programming language.
2. The method of claim 1, wherein, The integration of the compiled execution engine in the development project based on the first programming language comprises: The pre-compiled execution engine is an executable file, and the execution engine is used to execute source code based on a second programming language. A binding library corresponding to the execution engine is determined, and the binding library provides a programming interface for interaction between the first programming language and the execution engine. The binding library is added as a dependency to the development project based on the first programming language.
3. The method of claim 1, wherein, The compilation of the application source code based on the second programming language into bytecode by the execution engine to obtain the bytecode file corresponding to the application source code comprises: A handle scope instance of a sandbox is created by invoking the execution engine. A persistent context object is created in the handle scope instance. A context object scope is created by entering the created context object. In the context object scope, the application source code based on the second programming language is converted into a string, and the string is compiled into bytecode to obtain the bytecode file corresponding to the application source code.
4. The method of claim 1, wherein, The packing of the executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code, and the executable file corresponding to the development project into a target executable file comprises: After the compiled execution engine is linked with a dependent library in the development project for invoking the execution engine, the executable file corresponding to the compiled execution engine and the executable file corresponding to the development project are packed into one executable file. The target executable file about the application source code is generated according to the one executable file and the bytecode file corresponding to the application source code.
5. The method of claim 1, wherein, The invocation of the compiled execution engine to reconstruct and execute the business logic corresponding to the application source code from the bytecode file based on the executable file corresponding to the development project comprises: Based on the executable file corresponding to the development project, the compiled execution engine is called to obtain bytecode from the bytecode file, and the bytecode is converted into a cache data object suitable for the execution engine; A script compilation function in the compiled execution engine is called to reconstruct the business logic corresponding to the application source code from the cache data object through the script compilation function.
6. The method of claim 5, wherein, The method further comprises: When the reconstruction is successful, a script running function in the compiled execution engine is called to execute the business logic corresponding to the application source code, and an execution result is obtained; Webpage content is displayed according to the execution result.
7. The method of claim 5, wherein, The method further comprises: A handle scope instance of a sandbox is created by calling the compiled execution engine; A persistent context object is created in the handle scope instance; The created context object is entered to create a context object scope; In the context object scope, metadata is generated according to the bytecode, and script source code is generated according to the metadata; The business logic corresponding to the application source code is reconstructed by the script compilation function according to the cache data object and the script source code. The method further comprises:
8. The method of claim 1, wherein, An asynchronous program runtime library based on the first programming language is called in the development project; A handle scope instance of a sandbox is created by calling the compiled execution engine; A persistent context object is created in the handle scope instance; The created context object is entered to create a context object scope; In the context object scope, an event loop based on the first programming language is entered, and an asynchronous task based on the second programming language is scheduled and executed in the event loop through the asynchronous program runtime library. The method further comprises:
9. The method according to any one of claims 1 to 8, characterized in that, A persistent context object is created in a handle scope instance of a sandbox; The created context object is entered to create a context object scope; In the context object scope, a simulated global object is defined based on the first programming language, which is used to simulate a global object provided in a running environment of the first programming language, and is used to create a global variable or a global function in a development project based on the first programming language; A simulated process object is defined based on the first programming language, which is used to simulate a process object provided in a running environment of the first programming language, and is used to create a process object in a development project based on the first programming language. The apparatus comprises:
10. An application deployment apparatus characterized by comprising: An integration module is configured to integrate a compiled execution engine in a development project based on a first programming language, the execution engine being used to execute source code based on a second programming language, the first programming language being a compiled programming language, and the second programming language being an interpreted programming language; A compilation module is configured to compile application source code based on the second programming language into bytecode through the execution engine to obtain a bytecode file corresponding to the application source code after the execution engine is initialized in the development project; and A reconstruction module is configured to reconstruct the business logic corresponding to the application source code from the cache data object through a script compilation function in the compiled execution engine. a packaging module, configured to compile the development project based on the first programming language into an executable file; package the executable file corresponding to the compiled execution engine, the bytecode file corresponding to the application source code and the executable file corresponding to the development project into a target executable file; a deployment module, configured to deploy the target executable file to a target machine, so that after the target machine loads the target executable file, the compiled execution engine is invoked based on the executable file corresponding to the development project to reconstruct and execute the business logic corresponding to the application source code from the bytecode file, and the reconstructed business logic is implemented based on the first programming language. 11.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-10. The processor executes the computer program to implement the steps of the method in any one of claims 1 to 9.
12. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 9.
13. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 9.