A few days ago, i wrote about the Service Management Facility, a framework to manage services in Solaris. This framework enables Solaris to start services in a more intelligent manner. Albeit almost all services started by SMF are member of the project system it doesnīt have to be this way. You can specify the project used for a service.
Assigning a project to an already running service
This method is described in the
SMF FAQ. I will use an practical example. You run a server in the internet, but itīs under high load from spam bot. Youīve already created a project
sendmail and configured the resource management.
At the moment, the sendmail runs in the
system project:
# ps -o pid,project,args -ef | grep "sendmail" | grep -v "grep"
648 system /usr/lib/sendmail -Ac -q15m
647 system /usr/lib/sendmail -bd -q15m -C /etc/mail/local.cf
How do you start it as a part of a different project? Okay, check for an already configured project.
# svcprop -p start/project smtp:sendmail
svcprop: Couldn't find property `start/project' for instance `svc:/network/smtp:sendmail'.
Okay, nothing defined ... this makes it a little bit harder, because we canīt set the project only at the moment, as there is a bug in the restarter daemon. You need a fully populated start method. If the
svcprop run delivers you the name of a project, you can ignore the next block of commands:
svccfg -s sendmail setprop start/user = astring: root
svccfg -s sendmail setprop start/group = astring: :default
svccfg -s sendmail setprop start/working_directory = astring: :default
svccfg -s sendmail setprop start/resource_pool = astring: :default
svccfg -s sendmail setprop start/supp_groups = astring: :default
svccfg -s sendmail setprop start/privileges = astring: :default
svccfg -s sendmail setprop start/limit_privileges = astring: :default
svccfg -s sendmail setprop start/use_profile = boolean: false
Okay, now we can set the project property of the start method:
svccfg -s smtp/sendmail setprop start/project = astring: sendmail
Now we have to refresh the configuration of the service. After refreshing the service we can check the property:
# svcadm refresh sendmail
# svcprop -p start/project sendmail
sendmail
Okay, the new properties are active. Now restart the service:
# svcadm restart sendmail
Letīs check for the result:
# ps -o pid,project,args -ef | grep "sendmail" | grep -v "grep"
1539 sendmail /usr/lib/sendmail -bd -q15m -C /etc/mail/local.cf
1540 sendmail /usr/lib/sendmail -Ac -q15m
Configuring the project in a SMF manifest
Okay, you have written your own application and want to run it under the control of the SMF. You can define the project for the service in the manifest. You have to define the project in the start method of the manifest:
<exec_method type='method' name='start' exec='/path/to/method start' timeout_seconds='0' >
<method_context project=projectname' >
<method_credential user='someuser' />
</method_context>
</exec_method>
Thatīs all. The important part is the seond row of the fragment. We define the project as a part of the startup method context. The rest is done as described in the
SMF tutorial.
Okay, my tutorials getting bigger. This one has 7 parts. Well, this increase come from writting more, but shorter articles instead of a few longer ones. Well, this is next installment of the series about Less known Solaris features - today : Resource Man
Tracked: Mar 17, 14:56