Create a gist now

Instantly share code, notes, and snippets.

@djensen47 /
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"/>
<dependency name="network" grouping="require_all" restart_on="refresh" type="service">
<service_fmri value="svc:/milestone/network:default"/>
<dependency name="filesystem" grouping="require_all" restart_on="refresh" type="service">
<service_fmri value="svc:/system/filesystem/local"/>
<method_context working_directory="/home/admin">
<method_credential user="admin" group="staff" privileges='basic,net_privaddr' />
<envvar name="PATH" value="/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin"/>
<envvar name="HOME" value="/home/admin"/>
exec="mosca --credentials /etc/mosca/credentials.json --config /etc/mosca/config.json"
<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">
<stability value="Evolving"/>
<loctext xml:lang="C">mosca mqtt service</loctext>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment