- Production API - https://api.smartcitizen.me
- Basic Map Example - https://api.smartcitizen.me/examples/map (map)
- OAuth 2.0 (Implicit Grant) Example - http://example.smartcitizen.me (smartcitizen-oauth-example)
-
Copy the environment file, and edit variables, domain name, etc
cp env.example .env
-
Start basic services (recommended)
In a new terminal window do:
docker-compose up app db
See the
docker-compose.yml
filedepends_on:
section to see which containers depend on which.Available containers:
app
- Rails appdb
- Postgresredis
web
container which tries to get a certificate with Lets Encrypt.mqtt
EMQ + management interface on http://localhost:18083 admin:publicmqtt-task
a rake task which subscribes to themqtt
servicesidekiq
kairos
- Time series database on Cassandracassandra-1
- Stores the data
Start ALL of them (not recommended) with:
docker-compose up
-
(OPTIONAL) Start Cassandra cluster of 3 nodes
If you want to start Kairos with 3 Cassandra cluster with 3 nodes:
-
Uncomment the other 2 cassandras in
docker-compose.yml
file -
Edit the file
scripts/conf/kairosdb.properties
and change the following line:kairosdb.datastore.cassandra.cql_host_list=cassandra-1
docker-compose up kairos cassandra-1 cassandra-2 cassandra-3
-
-
Create the database (first time only)
If you need to perfom many operations, it might be better to
bash
into the container:docker-compose exec app bash
and from here you can do
bin/rails db:create
bin/rails db:schema:load
bin/rails db:seed
Or you can run them all at once with:
docker-compose exec app bin/rails db:setup
-
Removing everything
Remove all containers + data volumes with:
docker-compose down -v
apt-get install libmysqlclient-dev
brew tap homebrew/services
brew install redis postgresql
brew services start redis
brew services start postgresql
wget https://github.com/kairosdb/kairosdb/releases/download/v1.0.0/kairosdb-1.0.0-1.tar.gz
tar -zxvf kairosdb-1.0.0-1.tar.gz
./kairosdb/bin/kairosdb.sh run
git clone https://github.com/fablabbcn/smartcitizen
cd smartcitizen
bundle install
bundle exec bin/rails s
- SSH into the server
git pull
docker-compose build
docker-compose up -d
Documentation and scripts to deploy and operate cassandra in production are available on scripts/cassandra.
In the scripts/ folder there are backup and restore scripts for docker postgres.
-
Start an mqtt server like mosquitto
-
Subscribe to a topic (useful for debugging):
mosquitto_sub --topic '$queue/device/sck/abcdef/hello'
-
Start the mqtt rake task:
bundle exec rake mqtt:sub mqtt_host=localhost
-
Publish a packet
mosquitto_pub --message abcdef --topic '$queue/device/sck/abcdef/hello'
If running on Docker, there should be a EMQ Dashboard running on http://localhost:18083 (Log in with admin:public)
The following will send a message from the app
container to the mqtt
container:
-
Subscribe to a Websocket topic called "test" in the Dashboard http://localhost:18083/#/websocket
-
Access the rails console inside the
app
container:docker-compose exec app bin/rails console
-
Send a message to the
test
topic:MQTT::Client.connect('mqtt').publish('test', 'this is the message')
We supply a nodejs helper post-readings.js
tool to test sending massive amounts of data. Just like uploading a CSV file with a lot of readings.
To learn how to use it, do ./post-readings.js
Currently using this tool to manually handle versioning: https://github.com/gregorym/bump
Use this command to update the VERSION file + create a git tag
bump patch --tag
Then push the git tag with:
git push --tags
This work has received funding from the European Union's Horizon 2020 research and innovation program under the grant agreement No. 689954