# 手動啟動 Robotmon Service

* 此步驟需要使用終端機(Terminal)，請先開啟終端機
* 進入到 Service Manager 解壓縮後 bin 資料夾下，確認 adb 執行檔存在，並且有 windows, linux, mac 資料夾
* 取用 Service 需要確認 **手機支援度**
  1. 手機為 32 位元或 64 位元，確認使用 **app\_process** 或 **app\_process32** 來啟動 Java 執行程式
  2. 手機是否有 **`nohup`** 執行檔 (為了背景執行)，或可用 **`daemonize`** 取代，兩者都沒有的話可能必須依賴電腦
  3. 手機 Robotmon APP 安裝 APK位置 (使用 **`pm`** 指令來取得)
* 可以參考 Service 自動啟動器的指令（點擊兩下 **`Start`** 後會顯示啟動指令）
* 註: **`$`** 表示為下指令，實際操作時請刪除。**`#`** 為註解，非指令

## Mac

```
# 進入 service-mamager/bin 資料夾
$ cd bin

# 確認電腦已經連接手機 (只能連接一支手機)
$ ./adb.darwin devices
List of devices attached
LC53DYH00494 device

# 確認 app_process32 是否存在，不存在請改用 app_process
$ ./adb.darwin shell 'ls /system/bin/app_process32'
/system/bin/app_process32

# 確認 nohup 存在，不存在請改用 daemonize，兩者都不存在，可能要依賴電腦
$ ./adb.darwin shell 'ls /system/bin/nohup; ls /system/bin/daemonize'
/system/bin/nohup
/system/bin/daemonize: No such file or directory

# 確認 apk 安裝位置，請再次確認 Robotmon App 已經安裝
$ ./adb.darwin shell 'pm path com.r2studio.robotmon'
package:/data/app/com.r2studio.robotmon-1/base.apk

# 組合啟動 Service 指令
# 上述指令目的要湊出粗體字串
# nohup sh -c "LD_LIBRARY_PATH=/system/lib:/data/data/com.r2studio.robotmon/lib:/data/app/com.r2studio.robotmon-1/lib/arm:/data/app/com.r2studio.robotmon-2/lib/arm CLASSPATH=/data/app/com.r2studio.robotmon-1/base.apk app_process32 /system/bin com.r2studio.robotmon.Main $@" > /dev/null 2> /dev/null &

$ ./adb.darwin shell 'nohup sh -c "LD_LIBRARY_PATH=/system/lib:/data/data/com.r2studio.robotmon/lib:/data/app/com.r2studio.robotmon-1/lib/arm:/data/app/com.r2studio.robotmon-2/lib/arm CLASSPATH=/data/app/com.r2studio.robotmon-1/base.apk app_process32 /system/bin com.r2studio.robotmon.Main $@" > /dev/null 2> /dev/null &'

# 確認 Service 是否啟動，啟動成功會出現類似下列訊息，第二欄位為 process id
$ ./adb.darwin shell 'ps | grep app_process'
shell     9512  9508  1570960 39576 ffffffff ecc9c570 S app_process32

# 停止 Service
$ ./adb.darwin shell 'kill 9512'

# 確認是否成功停止 Service，沒出現額外訊息表示成功停止
$ ./adb.darwin shell 'ps | grep app_process'

# 進階排除錯誤，查看 Log。如果 Service 啟動失敗，手機會出現錯誤訊息來 Debug
$ ./adb.darwin logcat

# 訊息太多可用 grep 來 filter，關鍵字為 main, GoLog...
$ ./adb.darwin logcat | grep main
$ ./adb.darwin logcat | grep GoLog
```

## Linux

&#x20;指令同 Mac，只需要把 `./adb.darwin` 換成 `./adb.linux` 即可


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.robotmon.app/shi-yong/shou-service.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
