3 Star 13 Fork 6

Gitee 极速下载 / Moco-Java

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/dreamhead/moco
克隆/下载
cmd.md 4.19 KB
一键复制 编辑 原始数据 按行查看 历史

Standalone Command Line

Moco can be used as standalone to run with configuration and you can download standalone directly: Standalone Moco Runner

First of all, a JSON configuration file needs to be provided to start Moco.

[
  {
    "response" :
      {
        "text" : "foo"
      }
  }
]

(foo.json)

Table of Contents

Server Type

A server type is a must for Moco, you need specify your server type as first argument. Different server type will support different arguments.

HTTP Server

You can start a HTTP server by the following command:

java -jar moco-runner-<version>-standalone.jar http -p 12306 -c foo.json

HTTPS Server

A HTTPS server can be started by the following command:

java -jar moco-runner-<version>-standalone.jar https -p 12306 -c foo.json --https /path/to/cert.jks --cert mocohttps --keystore mocohttps

Socket Server

A socket server can be started by the following command:

java -jar moco-runner-<version>-standalone.jar socket -p 12306 -c foo.json

Configuration Files

One Configuration File

You can specify your configuration with -c.

java -jar moco-runner-<version>-standalone.jar http -p 12306 -c foo.json

Many Configuration Files

@Since 0.12.0

If you have many configuration files, you can use glob matcher as -c argument. But you need to make sure the configuration that don't conflict.

java -jar moco-runner-<version>-standalone.jar http -p 12306 -c "*.json"

Note: the quotation mark is required otherwise *.json will be parsed by your shell.

Port

Specific Port

You can specify server port with -p

java -jar moco-runner-<version>-standalone.jar http -p 12306 -c foo.json

Without Port

If you don't need any specified port, you run run Moco without port.

java -jar moco-runner-<version>-standalone.jar http -c foo.json

An available port will be picked up by Moco and you can see the port in console.

20 Oct 2015 22:10:18 [main] INFO  Server is started at 58593
20 Oct 2015 22:10:18 [main] INFO  Shutdown port is 58594

Quiet Mode

If you don't want see too many logs, you could make the server quiet with -q option.

java -jar moco-runner-<version>-standalone.jar http -p 12306 -c foo.json -q

Max Content Length

Max content length for a single request is set by default, but it is not enough for some case. You can set your own content length with content-length arguments.

java -jar moco-runner-<version>-standalone.jar http -p 12306 -c foo.json --content-length 2097152

Version

You can query Moco version by the following command:

java -jar moco-runner-<version>-standalone.jar version

Global Settings

You can run Moco instance with global settings.

java -jar moco-runner-<version>-standalone.jar http -p 12306 -g settings.json

Environment

Environment is a good feature, which allows you start your server with different environment from CLI.

java -jar moco-runner-<version>-standalone.jar http -p 12306 -g env.json -e remote

Shutdown

Moco instance can ben shutdown by shutdown command and its shutdown port. A shutdown port can be specified when start Moco instance.

java -jar moco-runner-<version>-standalone.jar http -p 12306 -c foo.json -s 9527

Or leave Moco to choose by default, the shutdown port will be shown on console.

Then you can use the shutdown port to shutdown the running Moco instance.

java -jar moco-runner-<version>-standalone.jar shutdown -s 9527
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/mirrors/Moco-Java.git
git@gitee.com:mirrors/Moco-Java.git
mirrors
Moco-Java
Moco-Java
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891