mirror of
https://github.com/jlengrand/cellar.git
synced 2026-03-10 08:01:19 +00:00
Move location of java code
This commit is contained in:
@@ -1,22 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
@@ -25,6 +7,7 @@
|
||||
<groupId>io.helidon.applications</groupId>
|
||||
<artifactId>helidon-mp</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>nl.lengrand</groupId>
|
||||
@@ -32,6 +15,10 @@
|
||||
<name>${project.artifactId}</name>
|
||||
<version>1.3.0</version>
|
||||
|
||||
<properties>
|
||||
<mainClass>nl.lengrand.cellar.Main</mainClass>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.helidon.microprofile.bundles</groupId>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package nl.lengrand;
|
||||
package nl.lengrand.cellar;
|
||||
|
||||
import nl.lengrand.faunadb.SensorApi;
|
||||
import nl.lengrand.cellar.faunadb.SensorApi;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package nl.lengrand;
|
||||
package nl.lengrand.cellar;
|
||||
|
||||
import nl.lengrand.cellar.Dht11Driver;
|
||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
@@ -1,4 +1,4 @@
|
||||
package nl.lengrand;
|
||||
package nl.lengrand.cellar;
|
||||
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package nl.lengrand;
|
||||
package nl.lengrand.cellar;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package nl.lengrand;
|
||||
package nl.lengrand.cellar;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package nl.lengrand;
|
||||
package nl.lengrand.cellar;
|
||||
|
||||
public class SensorValue {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package nl.lengrand.faunadb;
|
||||
package nl.lengrand.cellar.faunadb;
|
||||
|
||||
import com.faunadb.client.FaunaClient;
|
||||
import com.faunadb.client.query.Language;
|
||||
@@ -1,4 +1,4 @@
|
||||
package nl.lengrand.faunadb;
|
||||
package nl.lengrand.cellar.faunadb;
|
||||
|
||||
public class ConnectionException extends Exception {
|
||||
public ConnectionException(String errorMessage) {
|
||||
@@ -1,11 +1,11 @@
|
||||
package nl.lengrand.faunadb;
|
||||
package nl.lengrand.cellar.faunadb;
|
||||
import com.faunadb.client.FaunaClient;
|
||||
import com.faunadb.client.types.Value;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static com.faunadb.client.query.Language.*;
|
||||
import static nl.lengrand.faunadb.Connection.*;
|
||||
import static nl.lengrand.cellar.faunadb.Connection.*;
|
||||
|
||||
|
||||
/*
|
||||
@@ -1,15 +1,15 @@
|
||||
package nl.lengrand.faunadb;
|
||||
package nl.lengrand.cellar.faunadb;
|
||||
|
||||
import com.faunadb.client.query.Language;
|
||||
import com.faunadb.client.types.Value;
|
||||
import nl.lengrand.SensorValue;
|
||||
import nl.lengrand.cellar.SensorValue;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static com.faunadb.client.query.Language.*;
|
||||
import static com.faunadb.client.query.Language.Obj;
|
||||
import static nl.lengrand.faunadb.Connection.*;
|
||||
import static nl.lengrand.cellar.faunadb.Connection.*;
|
||||
|
||||
public class SensorApi {
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
/**
|
||||
* Quickstart MicroProfile example.
|
||||
*/
|
||||
package nl.lengrand;
|
||||
package nl.lengrand.cellar;
|
||||
15
cellar.service
Normal file
15
cellar.service
Normal file
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
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
|
||||
|
||||
SuccessExitStatus=143
|
||||
TimeoutStopSec=10
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
41
cellar.sh
Normal file
41
cellar.sh
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
SERVICE_NAME=cellar
|
||||
PATH_TO_JAR=/home/pi/projects/cellar-dist/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
|
||||
echo "$SERVICE_NAME started ..."
|
||||
else
|
||||
echo "$SERVICE_NAME is already running ..."
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
if [ -f $PID_PATH_NAME ]; then
|
||||
PID=$(cat $PID_PATH_NAME);
|
||||
echo "$SERVICE_NAME stopping ..."
|
||||
kill $PID;
|
||||
echo "$SERVICE_NAME stopped ..."
|
||||
rm $PID_PATH_NAME
|
||||
else
|
||||
echo "$SERVICE_NAME is not running ..."
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
if [ -f $PID_PATH_NAME ]; then
|
||||
PID=$(cat $PID_PATH_NAME);
|
||||
echo "$SERVICE_NAME stopping ...";
|
||||
kill $PID;
|
||||
echo "$SERVICE_NAME stopped ...";
|
||||
rm $PID_PATH_NAME
|
||||
echo "$SERVICE_NAME starting ..."
|
||||
/usr/bin/java -jar $PATH_TO_JAR
|
||||
echo "$SERVICE_NAME started ..."
|
||||
else
|
||||
echo "$SERVICE_NAME is not running ..."
|
||||
fi ;;
|
||||
esac
|
||||
Reference in New Issue
Block a user