Skip to content

Commit

Permalink
Merge pull request #3 from syswonder/app-split
Browse files Browse the repository at this point in the history
Add doc after app-split
  • Loading branch information
coolyjg authored Jan 8, 2024
2 parents a993263 + ec5a4be commit d746ee9
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 19 deletions.
10 changes: 10 additions & 0 deletions src/chap02/apps/iperf.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@

[iPerf3](https://github.com/esnet/iperf) 是一个用来测试网络实时带宽性能的工具.

## 拉取 Iperf 目录

执行:

```bash
git clone https://github.com/syswonder/rux-iperf ./apps/c/iperf/
```

该命令将拉取 iperf patch 等文件放到 `apps/c/iperf` 目录下。

## 构建、运行

通过下面的命令,在 RuxOS 上启动 iperf3 服务器:
Expand Down
42 changes: 23 additions & 19 deletions src/chap02/apps/nginx.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Nginx

RuxOS 支持在 Qemu 上运行 [Nginx](https://www.nginx.com/)构建服务器。
RuxOS 支持在 Qemu 上运行 [Nginx](https://www.nginx.com/) 构建服务器。

## 拉取 Nginx 目录

执行:

```bash
git clone https://github.com/syswonder/rux-nginx.git ./apps/c/nginx
```

该命令将拉取Nginx的编译配置文件等文件放到 `apps/c/nginx` 目录下。

## 创建文件系统镜像

Expand All @@ -12,15 +22,15 @@ RuxOS 支持在 Qemu 上运行 [Nginx](https://www.nginx.com/)构建服务器。

`/nginx/conf/mime.types`

其中,`error.log`是日志文件(但是实际上没有用到),`nginx.conf`是Nginx配置文件,告诉Nginx如何运行以及一些运行的参数`mime.type`是类型转化文件,告诉Nginx如何看待不同类型的文件。
其中,`error.log` 是日志文件(但是实际上没有用到),`nginx.conf` 是 Nginx 配置文件,告诉 Nginx 如何运行以及一些运行的参数`mime.type` 是类型转化文件,告诉Nginx如何看待不同类型的文件。

如果RuxOS根目录下没有disk.img,在运行时会自动创建一个符合条件的img
如果 RuxOS 根目录下没有 disk.img,在运行时会自动创建一个符合条件的 img。

如果您想要重新生成镜像,可以运行`apps/c/nginx`目录下的`create_nginx_img.sh`
如果您想要重新生成镜像,可以运行 `apps/c/nginx` 目录下的 `create_nginx_img.sh`

## 创建网页文件

在默认设置下运行时,`apps/c/nginx`目录下需要有一个名为html的文件夹,用来装载Nginx服务器的网页。如果您不想使用自己的网页,可以运行如下的命令来添加html的文件
在默认设置下运行时,`apps/c/nginx` 目录下需要有一个名为 html 的文件夹,用来装载 Nginx 服务器的网页。如果您不想使用自己的网页,可以运行如下的命令来添加 html 的文件

```shell
git clone https://github.com/syswonder/syswonder-web.git
Expand All @@ -29,11 +39,11 @@ cp -r syswonder-web/docs/* apps/c/nginx/html
rm -f -r syswonder-web
```

网页文件也可以设置在其他路径上,详见下面关于nginx.conf以及9p的内容
网页文件也可以设置在其他路径上,详见下面关于 nginx.conf 以及 9p 的内容

## 运行 Nginx

在上面的步骤完成后,运行下面的命令,可以在5555端口上启动Nginx服务器。
在上面的步骤完成后,在RuxOS的根目录下运行下面的命令,可以在5555端口上启动Nginx服务器。

```shell
make A=apps/c/nginx/ LOG=info NET=y BLK=y ARCH=aarch64 SMP=4 run
Expand Down Expand Up @@ -79,25 +89,19 @@ make A=apps/c/nginx/ LOG=info NET=y BLK=y FEATURES=virtio-9p V9P=y V9P_PATH=./ap
参数解释:

* `V9P`: 使用 `V9P=y` 来使能 qemu 的 virtio-9p 后端。
* `FEATURES=virtio-9p`告诉RuxOS启用9p功能
* `FEATURES=virtio-9p`告诉 RuxOS 启用 9p 功能
* `V9P_PATH`: `V9P_PATH` 指向 host 上的用于共享的目录,默认情况下这是网页文件的位置。

## nginx.conf

您可以修改`apps/c/nginx`目录下的nginx.conf文件来对Nginx的配置进行修改,包括修改Nginx服务器功能、修改服务器参数、修改Nginx运行选项等
您可以修改`apps/c/nginx`目录下的 nginx.conf 文件来对 Nginx 的配置进行修改,包括修改 Nginx 服务器功能、修改服务器参数、修改 Nginx 运行选项等

注意:

* 除http服务器之外的功能尚未验证



* 如果修改服务器参数(比如端口),请对qemu的相应设置(比如端口映射)做相应更改


* 除 http 服务器之外的功能尚未验证

* 修改完nginx.conf后请将其复制到文件系统镜像中,您可以通过在`apps/c/nginx`目录下运行`./create_nginx_img.sh`来完成
* 如果修改服务器参数(比如端口),请对 qemu 的相应设置(比如端口映射)做相应更改

* 修改完 nginx.conf 后请将其复制到文件系统镜像中,您可以通过在 `apps/c/nginx` 目录下运行 `./create_nginx_img.sh` 来完成

* 使用9pfs时的nginx.conf会有所不同,其内容在`apps/c/nginx`目录下的nginx_9p.conf中,可以通过`./create_nginx_img.sh 9p`的命令来将其复制到文件系统镜像中
* 使用 9pfs 时的 nginx.conf 会有所不同,其内容在 `apps/c/nginx` 目录下的 nginx_9p.conf 中,可以通过 `./create_nginx_img.sh 9p` 的命令来将其复制到文件系统镜像中
10 changes: 10 additions & 0 deletions src/chap02/apps/redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@

RuxOS 支持在 Qemu 上运行 [Redis](https://github.com/redis/redis) 服务器端。

## 拉取 Redis 目录

运行:

```bash
git clone https://github.com/syswonder/rux-redis ./apps/c/redis/
```

该命令将拉取 Redis 相关的 makefile 以及 patch 文件到 `apps/c/redis` 目录下。

## 创建文件系统镜像

在 RuxOS 根目录运行:
Expand Down
Binary file added translations/en/chap02/apps/img/nginx-res.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions translations/en/chap02/apps/iperf.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

[iPerf3](https://github.com/esnet/iperf) is a tool used to test real-time bandwidth performance in networks.

## Clone the Iperf Directory

Run:

```bash
git clone https://github.com/syswonder/rux-iperf ./apps/c/iperf/
```

This command will clone the Iperf patch and other files into the `apps/c/iperf` directory.

## Build and Run

Launch the iPerf3 server on RuxOS using the following command:
Expand Down
111 changes: 111 additions & 0 deletions translations/en/chap02/apps/nginx.md
Original file line number Diff line number Diff line change
@@ -1 +1,112 @@
# Nginx

RuxOS supports running [Nginx](https://www.nginx.com/)build servers on Qemu.

## Clone the Nginx Directory

Run:

```bash
git clone https://github.com/syswonder/rux-nginx.git ./apps/c/nginx
```

This command will clone the makefile and config files related to Nginx into the `apps/c/nginx` directory.

## Creating a File System Image

When running, it is necessary to ensure the following files exist in the file system:

`/nginx/logs/error.log`

`/nginx/conf/nginx.conf`

`/nginx/conf/mime.types`

Among these, `error.log` is a log file (although it's actually not used), `nginx.conf` is the Nginx configuration file, which tells Nginx how to operate and some operational parameters. `mime.types` is a file type conversion file, informing Nginx how to treat different types of files.

If there is no disk.img in the root directory of RuxOS, an appropriate img will be automatically created during runtime.

If you want to regenerate the image, you can run the create_nginx_img.sh script in the apps/c/nginx directory.

## Creating Web Page Files

By default, when running, the `apps/c/nginx` directory needs to have a folder named html to load the web pages of the Nginx server. If you do not want to use your own web pages, you can run the following command to add files to the html folder:

```shell
git clone https://github.com/syswonder/syswonder-web.git
mkdir -p apps/c/nginx/html
cp -r syswonder-web/docs/* apps/c/nginx/html
rm -f -r syswonder-web
```

Web page files can also be set in other paths, see below for details about nginx.conf and 9p.

## Running Nginx

After completing the steps above, run the following command to start the Nginx server on port 5555.

```shell
make A=apps/c/nginx/ LOG=info NET=y BLK=y ARCH=aarch64 SMP=4 run
```

Parameter explanation:

`A`: This parameter points to the directory where the Nginx application is located.
`LOG`: LOG denotes the log level of the output, with lower log levels meaning more detailed output. Options include: error, warn, info, debug, trace.
`NET`: This parameter enables qemu's virtio-net.
`BLK:` This parameter enables qemu's virtio-blk.
`ARCH`: ARCH indicates which architecture RuxOS is running on, with architectural options including: x86_64, aarch64, riscv64.
`SMP`: SMP enables the multi-core feature of RuxOS, with the number following it indicating the number of cores to launch.
Note, if you have modified the source code or run parameters after the first run, please run the following command to clean up the application files:

```shell
make clean_c A=apps/c/nginx
```

## How to Connect and Test

You can access the web page when visiting the server's port 5555.

![nginx_res](img/nginx-res.png)

## Using Musl libc

By default, RuxOS's Nginx uses a custom C application, ruxlibc.

By adding `MUSL=y` to the run command, you can use the standard musl libc integrated with RuxOS for compilation and linking.

## Using 9pfs

By default, RuxOS passes arguments to applications through the ARGS parameter in the command line, which may be inconvenient. RuxOS has now successfully integrated 9pfs, used for sharing file directories between the host and qemu, so parameters can be passed through the application's own configuration file.

Run the following command:

```shell
make A=apps/c/nginx/ LOG=info NET=y BLK=y FEATURES=virtio-9p V9P=y V9P_PATH=./apps/c/nginx/html/ ARCH=aarch64 SMP=4 run
```

Parameter explanation:

`V9P`: Use V9P=y to enable qemu's virtio-9p backend.
`FEATURES=virtio-9p`: Tells RuxOS to enable the 9p feature.
`V9P_PATH`: V9P_PATH points to the directory on the host that is shared, by default this is the location of the web page files.

## nginx.conf

You can modify the nginx.conf file in the apps/c/nginx directory to change the configuration of Nginx, including changing server functions, modifying server parameters, changing Nginx operation options, etc.

Note:

- Functions other than the http server have not been verified.



- If you modify server parameters (such as ports), please make corresponding changes to qemu's respective settings (such as port mapping).



- After modifying nginx.conf, please copy it to the file system image. You can do this by running ./create_nginx_img.sh in the apps/c/nginx directory.



- The nginx.conf used with 9pfs will be different, its content is in apps/c/nginx/nginx_9p.conf. You can copy it to the file system image using the command ./create_nginx_img.sh 9p.
10 changes: 10 additions & 0 deletions translations/en/chap02/apps/redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

RuxOS supports running the [Redis](https://github.com/redis/redis) server on Qemu.

## Clone the Redis Directory

Run:

```bash
git clone https://github.com/syswonder/rux-redis ./apps/c/redis/
```

This command will clone the makefile and patch files related to Redis into the `apps/c/redis` directory.

## Create File System Image

Run the following command in the RuxOS root directory:
Expand Down

0 comments on commit d746ee9

Please sign in to comment.