Create a gist now

Instantly share code, notes, and snippets.

@djensen47 /README.md
Last active Aug 29, 2015

What would you like to do?
Mosca Config Setup on SmartOS

Mosca Config Setup on SmartOS

  • install mosca
  • admin user should have read permission on /etc/mosca
  • admin user should have write permission on /var/log/mosca
  • copy config.json and credentials.json to /etc/mosca
$ sudo npm install -g mosca
$ sudo mkdir /var/log/mosca
$ sudo chown admin /var/log/mosca
$ sudo mkdir /etc/mosca
$ sudo chown admin /etc/mosca
$ svccfg import mosca-service-manifest.xml
$ svcadm enable mosca
{
"port": 1883,
"logger": {
"level": "info",
"name": "mosca",
"streams": [{
"type": "rotating-file",
"path": "/var/log/mosca/mosca.log",
"period": "1d",
"count": 10000
}]
},
"backend": {
"type": "redis",
"port": 6379,
"host": "localhost"
},
"persistence": {
"factory": "redis",
"port": 6379,
"host": "localhost"
}
}
{
"mqtt": {
"salt": "[redacted]",
"hash": "[redacted]",
"authorizePublish": "**/*",
"authorizeSubscribe": "**/*"
}
}
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type="manifest" name="mosca-service">
<service name="network/mqtt/mosca" type="service" version="1">
<create_default_instance enabled="true"/>
<single_instance/>
<dependency name="network" grouping="require_all" restart_on="refresh" type="service">
<service_fmri value="svc:/milestone/network:default"/>
</dependency>
<dependency name="filesystem" grouping="require_all" restart_on="refresh" type="service">
<service_fmri value="svc:/system/filesystem/local"/>
</dependency>
<method_context working_directory="/home/admin">
<method_credential user="admin" group="staff" privileges='basic,net_privaddr' />
<method_environment>
<envvar name="PATH" value="/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin"/>
<envvar name="HOME" value="/home/admin"/>
</method_environment>
</method_context>
<exec_method
type="method"
name="start"
exec="mosca --credentials /etc/mosca/credentials.json --config /etc/mosca/config.json"
timeout_seconds="60"/>
<exec_method
type="method"
name="stop"
exec=":kill"
timeout_seconds="60"/>
<property_group name="startd" type="framework">
<propval name="duration" type="astring" value="child"/>
<propval name="ignore_error" type="astring" value="core,signal"/>
</property_group>
<property_group name="application" type="application">
</property_group>
<stability value="Evolving"/>
<template>
<common_name>
<loctext xml:lang="C">mosca mqtt service</loctext>
</common_name>
</template>
</service>
</service_bundle>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment