日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

使用libscf.so實現(xiàn)SMF服務(wù)refresh方法( 五 )


#
# /etc/user_attr
#
# user attributes. see user_attr(4)
#
#pragma ident "@(#)user_attr 1.1 03/07/09 SMI"
#
adm::::profiles=Log Management
lp::::profiles=Printer Management
root::::auths=solaris.*,solaris.grant;profiles=Web Console Management,All;lock_after_retrIEs=no
hunter::::auths=solaris.smf.manage,solaris.smf.modify
假設(shè)本例中開發(fā)目錄和所有文件都位于/export/home/smfdemo目錄下,則將本例部署為SMF服務(wù)的步驟如下:
1. 使用svccfg(1M)命令檢查myapp.xml文件是否符合XML規(guī)范 。如果沒問題則不會有任何輸出,否則根據(jù)出錯提示修改myapp.xml 。
# /usr/sbin/svccfg validate /export/home/smfdemo/myapp.xml
2. 使用svcs(1)命令看是否已存在名為myapp的服務(wù) 。如有則必須修改在myapp.xml中定義的服務(wù)名,否則繼續(xù) 。
# /usr/bin/svcs application/myapp3. 使用svccfg(1M)命令加載myapp.xml所定義的服務(wù)并自動啟動服務(wù) 。
# /usr/sbin/svccfg import /export/home/smfdemo/myapp.xml4. 使用svcs(1)命令查看myapp服務(wù)狀態(tài) 。如狀態(tài)為online,則說明部署已成功且已運行,否則參看出錯原因以及SMF日志以確定問題所在,然后重復(fù)上文中相關(guān)的步驟后再試 。
# /usr/bin/svcs -xv application/myapp如果myapp部署成功,根據(jù)log_filename初始值設(shè)定,可以在/tmp目錄下找到myapp.log文件 。使用/usr/bin/tail -f /tmp/myapp.log命令可以查看日志輸出 。至此,myapp已經(jīng)部署完畢 。
測試
測試的目的是確認myapp的refresh方法可以正常工作 。方法是通過svccfg(1M)命令將myapp服務(wù)log_filename屬性值從 /tmp/myapp.log改為/tmp/myapp_new.log 。然后用svCADm refresh命令通知myapp服務(wù)重讀配置 。如果在/tmp目錄下新生成myapp_new.log,則說明refresh方法成功了 。具體步驟如下:
1. 確認myapp已經(jīng)啟動并處于online狀態(tài),并/tmp/myapp.log每隔5秒就有內(nèi)容輸出 。
# /usr/bin/svcs application/myapp
STATE STIME FMRI
online 10:53:57 svc:/application/myapp:default
# /usr/bin/tail -f /tmp/myapp.log
myapp is running at Fri Mar 10 10:57:12 2006
myapp is running at Fri Mar 10 10:57:17 2006
myapp is running at Fri Mar 10 10:57:22 2006
myapp is running at Fri Mar 10 10:57:27 2006
myapp is running at Fri Mar 10 10:57:32 2006
myapp is running at Fri Mar 10 10:57:37 2006
^C
2. 使用svccfg(1M)修改myapp服務(wù)myapp屬性組中l(wèi)og_filename屬性 。
# /usr/sbin/svccfg
svc:> select application/myapp
svc:/application/myapp> listprop
general framework
general/single_instance boolean true
milestone dependency
milestone/entitIEs fmri svc:/milestone/multi-user
milestone/grouping astring require_all
milestone/restart_on astring none
milestone/type astring service
start method
start/exec astring "/export/home/smfdemo/myapp.sh start"
start/timeout_seconds count 60
start/type astring method
stop method
stop/exec astring :kill
stop/timeout_seconds count 60
stop/type astring method
refresh method
refresh/exec astring ":kill -8"
refresh/timeout_seconds count 60
refresh/type astring method
myapp application
myapp/log_filename astring /tmp/myapp.log
svc:/application/myapp> setprop myapp/log_filename = "/tmp/myapp_new.log"
svc:/application/myapp> listprop
general framework
general/single_instance boolean true
milestone dependency
milestone/entities fmri svc:/milestone/multi-user
milestone/grouping astring require_all
milestone/restart_on astring none
milestone/type astring service
start method
start/exec astring "/export/home/smfdemo/myapp.sh start"
start/timeout_seconds count 60
start/type astring method
stop method
stop/exec astring :kill
stop/timeout_seconds count 60

推薦閱讀