Whilst setting up consul on SmartOS I noticed the packages distributed through pkgsrc were lagging behind a bit and the upstream “distribution” contains only the consul binary.

Running consul -dev in a tmux window will get boring pretty quickly, so I came up with the following SMF manifest using manifold which supports start, stop and refresh (triggers a configuration reload):

<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
        Created by Manifold
<service_bundle type="manifest" name="consul">

    <service name="site/consul" type="service" version="1">

        <create_default_instance enabled="true"/>


        <dependency name="network" grouping="require_all" restart_on="error" type="service">
            <service_fmri value="svc:/milestone/network:default"/>

        <dependency name="filesystem" grouping="require_all" restart_on="error" type="service">
            <service_fmri value="svc:/system/filesystem/local"/>

            <method_credential user="consul" group="consul"/>

        <exec_method type="method" name="start" exec="/usr/local/bin/consul agent -config-dir %{config_dir}" timeout_seconds="60"/>

        <exec_method type="method" name="stop" exec=":kill" timeout_seconds="60"/>
<exec_method type="method" name="refresh" exec=":kill -HUP" timeout_seconds="10"/>
        <property_group name="startd" type="framework">
            <propval name="duration" type="astring" value="child"/>
            <propval name="ignore_error" type="astring" value="core,signal"/>

        <property_group name="application" type="application">
            <propval name="config_dir" type="astring" value="/etc/consul.d"/>

        <stability value="Evolving"/>

                <loctext xml:lang="C">
                    Consul service discovery



Now import the manifest and start consul:

svccfg import consul.xml
svcadm enable consul

This was tested on SmartOS though it should work just fine on Solaris 10/11 and other illumos distributions.