Fixing fauna key bug

This commit is contained in:
Julien Lengrand-Lambert
2020-11-16 10:52:20 +01:00
parent 0f4f25cb66
commit b6582c4045
6 changed files with 22 additions and 15 deletions

View File

@@ -38,4 +38,14 @@ Stack Overflow Question : https://iot.stackexchange.com/questions/4662/in-what-f
# To run :
$ mvn clean package
$ mvn clean package
Location of service
```
$ cat /etc/systemd/system/cellar.service
$ cp cellar.service /etc/systemd/system/cellar.service
$ systemctl daemon-reload # if modified
$ chmod 777 /etc/systemd/system/cellar.service
$ journalctl -u cellar.service -f
```

View File

@@ -5,11 +5,14 @@ import com.faunadb.client.query.Language;
import com.faunadb.client.types.Value;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import java.util.concurrent.ExecutionException;
import static com.faunadb.client.query.Language.*;
@ApplicationScoped
public class Connection {
@Inject
@@ -22,6 +25,7 @@ public class Connection {
private FaunaClient client;
@PostConstruct
public void init(){
try {
this.client = createConnection();

View File

@@ -2,7 +2,6 @@ package nl.lengrand.cellar.store.faunadb;
import com.faunadb.client.query.Language;
import com.faunadb.client.types.Value;
import nl.lengrand.cellar.store.SensorApiProvider;
import nl.lengrand.cellar.store.SensorValue;
import nl.lengrand.cellar.store.SensorApi;
import org.eclipse.microprofile.config.inject.ConfigProperty;
@@ -21,13 +20,9 @@ public class FaunaSensorApi implements SensorApi {
@ConfigProperty(name = "sensor.api.fauna.collection", defaultValue = "sensors")
private String collection_name = "sensors";
@Inject
private Connection connection;
public FaunaSensorApi(){
this.connection = new Connection();
connection.init();
}
@Override
public void add(SensorValue value) {
try {

View File

@@ -15,7 +15,6 @@ import static nl.lengrand.cellar.store.faunadb.Connection.*;
*/
public class FaunaDbSetup {
public final static String DB_NAME = "cellar";
public final static String COLLECTION_NAME = "sensors";
public final static String UPDATE_DEVICE_NAME = "cellar_00";

View File

@@ -2,10 +2,10 @@
Description=Cellar Monitoring System
[Service]
User=pi
WorkingDirectory=/home/pi
ExecStart=/home/pi/projects/cellar-dist/cellar.sh start
ExecStop=/home/pi/projects/cellar-dist/cellar.sh stop
ExecReload=/home/pi/projects/cellar-dist/cellar.sh restart
WorkingDirectory=/home/pi/projects/cellar-release/cellar-dist
ExecStart=/home/pi/projects/cellar-release/cellar-dist/cellar.sh start
ExecStop=/home/pi/projects/cellar-release/cellar-dist/cellar.sh stop
ExecReload=/home/pi/projects/cellar-release/cellar-dist/cellar.sh restart
SuccessExitStatus=143
TimeoutStopSec=10

View File

@@ -1,14 +1,13 @@
#!/bin/sh
SERVICE_NAME=cellar
PATH_TO_JAR=/home/pi/projects/cellar-dist/cellar-app.jar
PATH_TO_JAR=cellar-app.jar
PID_PATH_NAME=/tmp/cellar.pid
export MONITORING_ENABLED=true
case $1 in
start)
echo "Starting $SERVICE_NAME ..."
if [ ! -f $PID_PATH_NAME ]; then
/usr/bin/java -jar -Dmonitoring.enabled=true $PATH_TO_JAR
/usr/bin/java -jar $PATH_TO_JAR
echo "$SERVICE_NAME started ..."
else
echo "$SERVICE_NAME is already running ..."