提交 7fca1ed7 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 762073a4
...@@ -18,9 +18,9 @@ Only the small system and standard system are supported. ...@@ -18,9 +18,9 @@ Only the small system and standard system are supported.
## How to Develop ## How to Develop
### Use Cases ### Use Cases
Upon startup, the init process first initializes the system and then parses the configuration file. The system classifies the configuration files into three types: Upon startup, the init process first initializes the system and then parses the configuration file. The system classifies the configuration files into three types:
1. init.cfg: default configuration file, which is defined by the init process and parsed first. 1. <strong>init.cfg</strong>: default configuration file, which is defined by the init process and parsed first.
2. /system/etc/init/*.cfg: configuration file defined by each subsystem. 2. <strong>/system/etc/init/*.cfg</strong>: configuration file defined by each subsystem.
3. /vendor/etc/init/*.cfg: configuration file defined by vendors. 3. <strong>/vendor/etc/init/*.cfg</strong>: configuration file defined by vendors.
If you need to add a configuration file, define its content as you want and copy it to the corresponding directory. If you need to add a configuration file, define its content as you want and copy it to the corresponding directory.
...@@ -81,14 +81,14 @@ The following is a template for defining a **.cfg** file. ...@@ -81,14 +81,14 @@ The following is a template for defining a **.cfg** file.
] ]
} }
``` ```
1. .cfg file: configuration file written in the JSON format. If the services or commands in it do not take effect, check whether the content format is correct. 1. <strong>.cfg file</strong>: configuration file written in the JSON format. If the services or commands in it do not take effect, check whether the content format is correct.
2. import: command used to import **.cfg** files. The files are parsed immediately after their path is parsed. 2. <strong>import</strong>: command used to import **.cfg** files. The files are parsed immediately after their path is parsed.
3. example1.cfg: **.cfg** file to be imported. 3. <strong>example1.cfg</strong>: **.cfg** file to be imported.
4. serviceName: service name, which is user-defined. 4. <strong>serviceName</strong>: service name, which is user-defined.
5. /system/bin/serviceName: full path and parameters of the executable file of the current service, in array format. 5. <strong>/system/bin/serviceName</strong>: full path and parameters of the executable file of the current service, in array format.
6. jobName1: job name, which is user-defined. 6. <strong>jobName1</strong>: job name, which is user-defined.
...@@ -84,7 +84,7 @@ A job is a command set, where you can manage the commands to be executed. A maxi ...@@ -84,7 +84,7 @@ A job is a command set, where you can manage the commands to be executed. A maxi
chown <i>uid</i> <i>gid</i> <i>target</i><br>Example:<br>chown 900 800 /storage/myDir<br>chown 100 100 /storage/myFile.txt chown <i>uid</i> <i>gid</i> <i>target</i><br>Example:<br>chown 900 800 /storage/myDir<br>chown 100 100 /storage/myFile.txt
</td> </td>
<td class="xl6621952" width="225" style="border-top:none;border-left:none; width:169pt"> <td class="xl6621952" width="225" style="border-top:none;border-left:none; width:169pt">
Modifies the owner group. <strong>chown</strong>, <strong>uid</strong>, <strong>gid</strong>, and <i>target</i> must be separated by only one space. Modifies the owner group. <strong>chown</strong>, <i>uid</i>, <i>gid</i>, and <i>target</i> must be separated by only one space.
</td> </td>
<td class="xl6621952" width="190" style="border-top:none;border-left:none; width:143pt"> <td class="xl6621952" width="190" style="border-top:none;border-left:none; width:143pt">
Small and standard systems Small and standard systems
......
...@@ -2,9 +2,13 @@ ...@@ -2,9 +2,13 @@
## Overview ## Overview
### Basic Concepts ### Basic Concepts
- Introduction to begetctl
For details, see [begetctl Commands](#table14737791480). - begetctl
For details about begetctl, see [begetctl Commands](#table14737791480).
- bootchart plug-in - bootchart plug-in
The bootchart plug-in is an open source tool used to evaluate system performance during Linux startup. It automatically collects information such as the CPU usage, disk throughput, and process status, and displays the evaluation result in graphics to facilitate system startup optimization. The bootchart plug-in is an open source tool used to evaluate system performance during Linux startup. It automatically collects information such as the CPU usage, disk throughput, and process status, and displays the evaluation result in graphics to facilitate system startup optimization.
### Constraints ### Constraints
...@@ -149,8 +153,8 @@ bootchart is available only for the standard system, and begetctl is available f ...@@ -149,8 +153,8 @@ bootchart is available only for the standard system, and begetctl is available f
proc_diskstats.log<br> proc_diskstats.log<br>
proc_ps.log<br> proc_ps.log<br>
proc_stat.log<br> proc_stat.log<br>
7. Run the **tar -zcvf bootchart.tgz *** command to compress the **bootchart.tgz** file (available only for Linux) and copy the compressed file to the **linux:bootchart-master** directory. 7. Run the <strong>tar -zcvf bootchart.tgz *</strong> command to compress the <strong>bootchart.tgz</strong> file (available only for Linux) and copy the compressed file to the <strong>linux:bootchart-master</strong> directory.
8. Run the following command in the **bootchart-master** directory: 8. Run the following command in the <strong>bootchart-master</strong> directory:
``` ```
python3 pybootchartgui.py -f pdf bootchart.tgz python3 pybootchartgui.py -f pdf bootchart.tgz
``` ```
......
...@@ -70,11 +70,11 @@ Service configuration allows you to configure services on demand to create diffe ...@@ -70,11 +70,11 @@ Service configuration allows you to configure services on demand to create diffe
The CPU core binding, priority, MAC address, and AccessToken information of the service process can be configured in the configuration file during process startup. The CPU core binding, priority, MAC address, and AccessToken information of the service process can be configured in the configuration file during process startup.
- Support of CPU core binding for service processes (through modification of the **\*.cfg** file) - Support of CPU core binding for service processes (through modification of the <strong>*.cfg</strong> file)
- Support of priority setting for service processes (through modification of the **\*.cfg** file) - Support of priority setting for service processes (through modification of the <strong>*.cfg</strong> file)
- Support of MAC address setting (that is, SELinux tag setting) for service processes (through modification of the **\*.cfg** file) - Support of MAC address setting (that is, SELinux tag setting) for service processes (through modification of the <strong>*.cfg</strong> file)
- Support of AccessToken setting for service processes and distributed capability setting for system service processes (through modification of the **\*.cfg** file) - Support of AccessToken setting for service processes and distributed capability setting for system service processes (through modification of the <strong>*.cfg</strong> file)
- Support of the suppression mechanism for service processes (through modification of the **\*.cfg** file) - Support of the suppression mechanism for service processes (through modification of the <strong>*.cfg</strong> file)
The following is the example configuration for enhanced init process startup and recycling: The following is the example configuration for enhanced init process startup and recycling:
``` ```
...@@ -111,7 +111,7 @@ The service management module is available only for the mini system and standard ...@@ -111,7 +111,7 @@ The service management module is available only for the mini system and standard
## How to Develop ## How to Develop
### Use Cases ### Use Cases
By parsing the ***.cfg** file, you can obtain **service** fields, and then set and start the service. By parsing the <strong>*.cfg</strong> file, you can obtain **service** fields, and then set and start the service.
### Parameters ### Parameters
**Table 1** Description of service fields **Table 1** Description of service fields
...@@ -240,8 +240,8 @@ By parsing the ***.cfg** file, you can obtain **service** fields, and then set a ...@@ -240,8 +240,8 @@ By parsing the ***.cfg** file, you can obtain **service** fields, and then set a
Suppression mechanism for services. If the number of times a service is restarted exceeds the value N within the specified period T, the system will be restarted. Suppression mechanism for services. If the number of times a service is restarted exceeds the value N within the specified period T, the system will be restarted.
</td> </td>
<td class="xl6621805" width="242" style="border-top:none;border-left:none; width:182pt"> <td class="xl6621805" width="242" style="border-top:none;border-left:none; width:182pt">
Standard system:<br>Type: int array, for example, **"critical": [M, N, T]**.<br>- **M**: enable flag (**0**: disable; **1**: enable).<br>- **N**: number of times the service is started.<br>- **T**: period of time, in seconds.<br> Both **M** and **N** are greater than **0**.<br> Standard system:<br>Type: int array, for example, <strong>"critical": [M, N, T]</strong>.<br>- **M**: enable flag (**0**: disable; **1**: enable).<br>- **N**: number of times the service is started.<br>- **T**: period of time, in seconds.<br> Both **M** and **N** are greater than **0**.<br>
Small and standard systems:<br>Type: int, for example, **"critical": M**.<br>M: enable flag (**0**: disable; **1**: enable).<br> By default, **N** is **4** and **T** is **20**. Small and standard systems:<br>Type: int, for example, <strong>"critical": M</strong>.<br>**M**: enable flag (**0**: disable; **1**: enable).<br> By default, **N** is **4** and **T** is **20**.
</td> </td>
<td class="xl6621805" width="173" style="border-top:none;border-left:none; width:130pt"> <td class="xl6621805" width="173" style="border-top:none;border-left:none; width:130pt">
Standard system Standard system
...@@ -255,7 +255,7 @@ By parsing the ***.cfg** file, you can obtain **service** fields, and then set a ...@@ -255,7 +255,7 @@ By parsing the ***.cfg** file, you can obtain **service** fields, and then set a
Number of CPU cores bound to the service. Number of CPU cores bound to the service.
</td> </td>
<td class="xl6621805" width="242" style="border-top:none;border-left:none; width:182pt"> <td class="xl6621805" width="242" style="border-top:none;border-left:none; width:182pt">
Type: int array, for example, **"cpucore": [N1, N2, ...]**. **N1** and **N2** indicate the indices of the CPU cores to be bound. For a single-core device, **cpucore** is **0**. Type: int array, for example, <strong>"cpucore": [N1, N2, ...]</strong>. **N1** and **N2** indicate the indices of the CPU cores to be bound. For a single-core device, **cpucore** is **0**.
</td> </td>
<td class="xl6621805" width="173" style="border-top:none;border-left:none; width:130pt"> <td class="xl6621805" width="173" style="border-top:none;border-left:none; width:130pt">
Standard system Standard system
...@@ -269,7 +269,7 @@ By parsing the ***.cfg** file, you can obtain **service** fields, and then set a ...@@ -269,7 +269,7 @@ By parsing the ***.cfg** file, you can obtain **service** fields, and then set a
Distributed service capability (for standard system or higher) Distributed service capability (for standard system or higher)
</td> </td>
<td class="xl6621805" width="242" style="border-top:none;border-left:none; width:182pt"> <td class="xl6621805" width="242" style="border-top:none;border-left:none; width:182pt">
Type: string array, for example, **"d-caps": ["OHOS_DMS"]**. Type: string array, for example, <strong>"d-caps": ["OHOS_DMS"]</strong>.
</td> </td>
<td class="xl6621805" width="173" style="border-top:none;border-left:none; width:130pt"> <td class="xl6621805" width="173" style="border-top:none;border-left:none; width:130pt">
Standard system Standard system
...@@ -283,7 +283,7 @@ By parsing the ***.cfg** file, you can obtain **service** fields, and then set a ...@@ -283,7 +283,7 @@ By parsing the ***.cfg** file, you can obtain **service** fields, and then set a
Ability privilege level (for standard system or higher). Ability privilege level (for standard system or higher).
</td> </td>
<td class="xl6621805" width="242" style="border-top:none;border-left:none; width:182pt"> <td class="xl6621805" width="242" style="border-top:none;border-left:none; width:182pt">
Type: string, for example, **"apl": "system_core"**. The value can be **system_core** (default), **normal**, or **system_basic**. Type: string, for example, <strong>"apl": "system_core"</strong>. The value can be **system_core** (default), **normal**, or **system_basic**.
</td> </td>
<td class="xl6621805" width="173" style="border-top:none;border-left:none; width:130pt"> <td class="xl6621805" width="173" style="border-top:none;border-left:none; width:130pt">
Standard system Standard system
...@@ -297,7 +297,7 @@ By parsing the ***.cfg** file, you can obtain **service** fields, and then set a ...@@ -297,7 +297,7 @@ By parsing the ***.cfg** file, you can obtain **service** fields, and then set a
Service startup mode (for standard system or higher). Service startup mode (for standard system or higher).
</td> </td>
<td class="xl6721805" width="242" style="border-top:none;border-left:none; width:182pt"> <td class="xl6721805" width="242" style="border-top:none;border-left:none; width:182pt">
Type: string, for example, **"start-mode": "condition"**. The value can be **boot**, **normal**, or **condition**. For details, see init Service Startup Control.</a> Type: string, for example, <strong>"start-mode": "condition"</strong>. The value can be **boot**, **normal**, or **condition**. For details, see init Service Startup Control.</a>
</td> </td>
<td class="xl6621805" width="173" style="border-top:none;border-left:none; width:130pt"> <td class="xl6621805" width="173" style="border-top:none;border-left:none; width:130pt">
Standard system Standard system
...@@ -311,7 +311,7 @@ By parsing the ***.cfg** file, you can obtain **service** fields, and then set a ...@@ -311,7 +311,7 @@ By parsing the ***.cfg** file, you can obtain **service** fields, and then set a
Whether on-demand startup is enabled. Whether on-demand startup is enabled.
</td> </td>
<td class="xl6721805" width="242" style="border-top:none;border-left:none; width:182pt"> <td class="xl6721805" width="242" style="border-top:none;border-left:none; width:182pt">
Type: bool, for example, **"ondemand": true**. This feature is available only for the small system running the Linux kernel. For details, see init Service On-Demand Startup.</a> Type: bool, for example, <strong>"ondemand": true</strong>. This feature is available only for the small system running the Linux kernel. For details, see init Service On-Demand Startup.</a>
</td> </td>
<td class="xl6621805" width="173" style="border-top:none;border-left:none; width:130pt"> <td class="xl6621805" width="173" style="border-top:none;border-left:none; width:130pt">
Small and standard systems Small and standard systems
...@@ -359,10 +359,10 @@ By parsing the ***.cfg** file, you can obtain **service** fields, and then set a ...@@ -359,10 +359,10 @@ By parsing the ***.cfg** file, you can obtain **service** fields, and then set a
| permissions | Permissions of the socket node file. This field is valid only for sockets that have entity node files, such as the AF_UNIX address family.| | permissions | Permissions of the socket node file. This field is valid only for sockets that have entity node files, such as the AF_UNIX address family.|
| uid | User ID of the socket node file. This field is valid only for sockets that have entity node files, such as the AF_UNIX address family.| | uid | User ID of the socket node file. This field is valid only for sockets that have entity node files, such as the AF_UNIX address family.|
| gid | Group ID of the socket node file. This field is valid only for sockets that have entity node files, such as the AF_UNIX address family.| | gid | Group ID of the socket node file. This field is valid only for sockets that have entity node files, such as the AF_UNIX address family.|
| option | Socket option. This field is passed when **setsockopt** is called. Currently, the available options include **SOCKET_OPTION_PASSCRED**, **SOCKET_OPTION_RCVBUFFORCE**, **SOCK_CLOEXEC**, and **SOCK_NONBLOCK**.| | option | Socket option. This field is passed when **setsockopt** is called. Currently, the available options include <strong>SOCKET_OPTION_PASSCRED</strong>, <strong>SOCKET_OPTION_RCVBUFFORCE</strong>, <strong>SOCK_CLOEXEC</strong>, and <strong>SOCK_NONBLOCK</strong>.|
### Available APIs ### Available APIs
**Table 3** FD proxy APIs<a name="table14737791479"></a> **Table 3** FD proxy APIs
| API | Function| Description | | API | Function| Description |
| ---------- | ---------- |--------| | ---------- | ---------- |--------|
| int *ServiceGetFd(const char *serviceName, size_t *outfdCount) | Obtains the proxy FD from the init process.| Return value: Returns the pointer to the fd array if the operation is successful; returns **NULL** otherwise. (Note: Manual release is required.)<br>Arguments:<br> **serviceName**: service name.<br>**outfdCount**: length of the returned fd array.| | int *ServiceGetFd(const char *serviceName, size_t *outfdCount) | Obtains the proxy FD from the init process.| Return value: Returns the pointer to the fd array if the operation is successful; returns **NULL** otherwise. (Note: Manual release is required.)<br>Arguments:<br> **serviceName**: service name.<br>**outfdCount**: length of the returned fd array.|
......
...@@ -26,10 +26,10 @@ Figure 1 System parameter operation primitives ...@@ -26,10 +26,10 @@ Figure 1 System parameter operation primitives
**Table 2** System parameter names **Table 2** System parameter names
| Type| Example| Description| | Type| Name| Example| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| Parameter name | const.product.**name** | Complete system parameter name. It does not end with a period (.). | | Name| Parameter Name | const.product.**name** | Complete system parameter name. It does not end with a period (.). |
| Parameter directory | const.product **.** | Name of the directory storing system parameters with the same prefix. It ends with a period (.).| | Directory| Parameter Directory | const.product **.** | Name of the directory storing system parameters with the same prefix. It ends with a period (.).|
- Type - Type
...@@ -90,11 +90,11 @@ Each subsystem defines the system parameters of its own modules, including the s ...@@ -90,11 +90,11 @@ Each subsystem defines the system parameters of its own modules, including the s
const.product.="root:root:660" const.product.="root:root:660"
``` ```
As shown above, we can use **parameter directory** to define the same access permission for system parameters with the same prefix. The DAC information is divided into three segments, user, group, and UGO rule information, which are separated using a semicolon (:). As shown above, we can use **parameter directory** to define the same access permission for system parameters with the same prefix. The DAC information is divided into three segments, user, group, and UGO rule, which are separated using a semicolon (:).
The following figure shows the structure of the UGO rule information. The following figure shows the structure of the UGO rule.
**Figure 2** UGO rule information **Figure 2** UGO rule structure
![UGO rule](figure/dac-definition.png) ![UGO rule](figure/dac-definition.png)
...@@ -132,7 +132,7 @@ You can set specific system parameters as needed to meet your service demand. ...@@ -132,7 +132,7 @@ You can set specific system parameters as needed to meet your service demand.
| -------- | -------- | | -------- | -------- |
| param get [**key**] | Obtains the system parameter value of the specified key. If no key name is specified, all system parameter values will be returned.| | param get [**key**] | Obtains the system parameter value of the specified key. If no key name is specified, all system parameter values will be returned.|
| param set **key value** | Sets the specified value for the specified key.| | param set **key value** | Sets the specified value for the specified key.|
| param wait **key** **value** | Waits for the system parameter value of the specified key to match the specified value. Fuzzy match is supported. For example, ***** indicates any value, and **val*** indicates matching of only the first three val characters.| | param wait **key** **value** | Waits for the system parameter value of the specified key to match the specified value. Fuzzy match is supported. For example, <strong>*</strong> indicates any value, and <strong>val*</strong> indicates matching of only the first three val characters.|
| param watch | Observes value change of a system parameter asynchronously.| | param watch | Observes value change of a system parameter asynchronously.|
- syspara APIs - syspara APIs
...@@ -177,9 +177,9 @@ You can set specific system parameters as needed to meet your service demand. ...@@ -177,9 +177,9 @@ You can set specific system parameters as needed to meet your service demand.
1. System parameter definition 1. System parameter definition
You can define default system parameters and implement permission control on them by configuring the subsystem or product **.para** and **.para.dac** files. You can define default system parameters and implement permission control on them by configuring the subsystem or product <strong>.para</strong> and <strong>.para.dac</strong> files.
​ On a standard system, use the **ohos_prebuilt_para** template to install the configuration file to the **/etc/param/** directory. The following is an example of the GN script: ​ On a standard system, use the <strong>ohos_prebuilt_para</strong> template to install the configuration file to the <strong>/etc/param/</strong> directory. The following is an example of the GN script:
```go ```go
import("//base/startup/init_lite/services/etc/param/param_fixer.gni") import("//base/startup/init_lite/services/etc/param/param_fixer.gni")
...@@ -197,7 +197,7 @@ You can set specific system parameters as needed to meet your service demand. ...@@ -197,7 +197,7 @@ You can set specific system parameters as needed to meet your service demand.
} }
``` ```
On a small system, run the **copy** command to copy the corresponding system parameter definition file to the **system/etc/param** directory. On a small system, run the <strong>copy</strong> command to copy the corresponding system parameter definition file to the <strong>system/etc/param</strong> directory.
```go ```go
copy("ohos.para") { copy("ohos.para") {
sources = [ "//base/startup/init_lite/services/etc/param/ohos.para" ] sources = [ "//base/startup/init_lite/services/etc/param/ohos.para" ]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册