dm Shell

工程 | Christopher Frost | 2009年10月15日 | ...

dm Server 有一個新的命令列 shell。它目前與現有的 Equinox shell 一起提供,並將取代它用於 2.0 版本。Equinox shell 的改進包括基本的 Tab 補全和命令歷史記錄。

dm Shell 在本地和透過 SSH 遠端都可用。當透過 './startup.sh -shell' 選項啟動伺服器在本地使用時,一旦 dm 核心啟動,它將接管控制檯輸出。控制檯輸出仍然可以在事件日誌中檢視。無論哪種方式,首先出現的是一個 ASCII 藝術啟動畫面,然後是命令提示符 ':> '

[13:36:54 ~]: ssh -p 2402 admin@localhost
admin@localhost's password: 

     @@@ ***                                                                       
    @@@ *****            .__.                  .__.            .__.  .__.          
   @@@@ ******         __|  |  _____     _____.|  |__    ____  |  |  |  |          
   @@@@@@ ****        / __  | /     \   /  ___/|  |  \ ./ __ \ |  |  |  |       
    @@@@@ ***        / /_/  ||  Y Y  \  \___ \ |   Y  \\  ___/ |  |__|  |__   
     @@@ ***         \______||__|_|__/ /_____/ |___|__/ \____/ |____/|____/      

Type 'help' to see the available commands.
:> 

遠端訪問 dm Shell 需要密碼,安全性由 JAAS 認證提供,與 dm Console 的 ID/密碼相同。預設是 'admin/springsource'。這可以透過 'config' 目錄中的 'com.springsource.kernel.users.properties' 檔案進行配置。

列出捆綁包

進入 shell 後,輸入 'help' 以檢視可用命令列表。當命令輸入到一半時,只需按 'TAB' 即可檢視該命令可能的補全列表,而無需返回並再次輸入 'help'

'bundles' 命令開始,這將顯示系統中的 使用者區域 捆綁包。顯示了它們的狀態、名稱、版本以及它們是否由 Spring 提供支援。除了少數用於管理使用者區域的核心捆綁包及其服務之外,核心的任何部分都對使用者安裝的工件不可見。這使得它更清晰,因為可見的系統捆綁包和服務要少得多。

:> bundles
Id  State         Name-Version
0   Active        org.eclipse.osgi-3.5.1.R35x_v20090827
1   Active        com.springsource.region.user-0.0.0
2   Resolved      org.springframework.aop-3.0.0.CI-395
3   Resolved      org.springframework.asm-3.0.0.CI-395
....
46  Active      S com.springsource.server.admin.web-2.0.0.M5
47  Active        com.springsource.javax.servlet.jsp.jstl-1.1.2
48  Active        com.springsource.org.apache.taglibs.standard-1.1.2
49  Active        org.springframework.context.support-3.0.0.CI-395
50  Active        org.springframework.jdbc-3.0.0.CI-395
51  Active        org.springframework.js-2.0.8.RELEASE
52  Active        org.springframework.transaction-3.0.0.CI-395
53  Active        org.springframework.web.servlet-3.0.0.CI-395
54  Active      S com.springsource.server.repository.hosted-2.0.0.M5-com.springsource.server.repository.hosted.core-2.0.0.M5
55  Active        com.springsource.server.repository.hosted-2.0.0.M5-com.springsource.server.repository.hosted.web-2.0.0.M5
56  Active        com.springsource.server.repository.hosted-2.0.0.M5-com.springsource.server.repository.hosted-synthetic.context-2.0.0.M5
57  Active        com.springsource.server.splash-2.0.0.M5

執行生命週期操作

執行操作也很容易,例如安裝捆綁包。輸入 'install file:/path.to.bundle.jar'

:> install file:/Users/chrisfrost/Desktop/com.bar.import-1.0.0.jar
60  Installed     com.bar.importer-1.0.0

捆綁包已安裝,但當我們嘗試 'start' 它時出現錯誤。嘗試啟動捆綁包時,顯示了捆綁包缺少必需的依賴項。

:> start 60
Error occured while starting bundle '[60] com.bar.importer-1.0.0' : The bundle could not be resolved. Reason: Missing Constraint: Import-Package: com.foo; version="[1.0.0,2.0.0)"
:> 

使用 'diag' 命令可以隨時輕鬆獲取此資訊。顯示的資訊將與嘗試啟動捆綁包時日誌檔案中顯示的資訊相同。

:> diag 60
Resolution report for bundel 60  Installed     com.bar.importer-1.0.0

Cannot resolve: com.bar.importer
    Resolver report:
        An Import-Package could not be resolved. Caused missing constraint <Import-Package: com.foo; version="[1.0.0,2.0.0)"> in bundle <com.bar.importer_1.0.0>

:> 

我們可以安裝一個滿足依賴項的捆綁包,然後再次 'start' 我們的原始捆綁包,這次一切順利。

捆綁包詳情

這是一個非常簡單的捆綁包,可以透過輸入 'bundle 60' 來詳細檢視。請記住有 Tab 補全功能,所以只需 'bu TAB 60' 即可完成命令。這裡顯示了此捆綁包匯入和匯出的所有包。捆綁包名稱前的 'S' 表示該捆綁包具有 Spring 上下文。

:> bundle 60
Bundle report for 60  Active      S com.bar.importer-1.0.0

Imported packages:
    com.foo-[1.0.0, 2.0.0)

Exported packages:

:> bundle 61
Bundle report for 61  Resolved      com.foo.exporter-1.0.0

Imported packages:

Exported packages:
    com.foo-1.0.0

:> 

我們可以看到它現在匯入了之前導致錯誤的包。顯示的第二個捆綁包是匯出該包的捆綁包。

檢視配置

其他一些可用命令包括 'config''configs',它們將顯示已安裝的配置及其屬性。

:> configs
Pid
com.springsource.kernel
com.springsource.repository
com.springsource.server.repository.hosted
com.springsource.osgi.medic
com.springsource.kernel.users
com.springsource.kernel.jmxremote.access

:> config com.springsource.osgi.medic
Pid                 = com.springsource.osgi.medic
Factory pid         = null
Bundle location     = null

dump.root.directory = serviceability/dump
log.wrapSysErr      = true
log.wrapSysOut      = true
service.pid         = com.springsource.osgi.medic

:> 

顯示的是可用配置列表和 medic 配置的屬性。完成 dm Shell 後,有兩種方法可以退出。'exit' 將簡單地退出 shell,而 'shutdown' 將呼叫伺服器上的關閉命令,並且 shell 會話將作為關閉的一部分終止。

:> exit
Goodbye.
Connection to localhost closed.
[14:24:03 ~]: 

即將推出...

在 2.0 版本釋出之前,我們正在對 shell 進行更多的工作,屆時將有一個完整的使用者指南,我猜還會有另一篇部落格或截圖影片。所以,如果您想看到一些殺手級功能,請大聲說出來。

獲取 Spring 新聞通訊

透過 Spring 新聞通訊保持聯絡

訂閱

領先一步

VMware 提供培訓和認證,助您加速進步。

瞭解更多

獲得支援

Tanzu Spring 提供 OpenJDK™、Spring 和 Apache Tomcat® 的支援和二進位制檔案,只需一份簡單的訂閱。

瞭解更多

即將舉行的活動

檢視 Spring 社群所有即將舉行的活動。

檢視所有