Skip to content

Commit

Permalink
change readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonbeckas committed Sep 26, 2020
1 parent 01702d5 commit 6686335
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 27 deletions.
47 changes: 32 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,53 @@ With ProcessWatcher you can track processes and running a commandline command if


## Install
1. Download the program from [Releases](https://github.com/Jonbeckas/processWatcher/releases)

### With Script
1. ```sh
curl -s https://raw.githubusercontent.com/Jonbeckas/processWatcher/master/install.sh | sudo bash
```

1. Make sure its run when your system boots

### Manual

1. Clone repo
1. ```sh
sudo ./gradlew testInstallUnix
```

## Configurate
## Configure
1. Run watcher one times manualy
1. Watcher creates a `config.json` in the home directory or in the directory where the watcher.jar is
1. Watcher creates a `config.json`. This is located at /usr/share/processwatcher/ when it can write to this directory.
Else it writes the configuration to the path of its executible or to the current working directory
1. Open config.json in a text editor
1. For Example:
```json
{
"attemps": 5,
"refresh": 10,
"link": ["link to another config.json","link to another config.json"],
"work": [
{
"procname": "process Name like in tasklist.exe or ps -e",
"if": "command if process run",
"else": "command if process is not running "
},
{
"linkconf": "link to another config.json"
},
{
"keepalive": "restarts the programm if it is not running"
"process": "the programm",
"arguments": ["list","of","arguments"],
"id": "id",
"test": {
"test": "test command",
"expect": "expected return value of test command"
}
}
]
}
```
### Additional Hints
**attempts**: How often ProcessWatcher should try to start keepAlive programes in one refresh circle
**attempts**: How often ProcessWatcher should try to start keepAlive programes in one refresh circle. No impact in child confs

**refresh:** How long ProcessWatcher should wait between the refresh circles. No impact in child confs

**refresh:** How long ProcessWatcher should wait between the refresh circles
**Keepalive:** Immediately Restart the Process if it stops. Logs output in logFile and try the number of attempts to restart. The attempts resets if one refresh circle is over.

**Test:** Is not necessary

**Keepalive:** Imedeatly Restart the Process if it stops. Logs output in logFile and try the number of attempts to restart. The attempts resets if one refresh circle is over.
## CLI
Use watchercli for accessing the api
7 changes: 7 additions & 0 deletions cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,10 @@ task<Exec>("buildUnix") {
commandLine("bash","-c","echo \"#!/usr/bin/java -jar\" > watchercli")
commandLine("bash","-c","cat *.jar >> watchercli")
}

task<Exec>("testInstallUnix") {
dependsOn("buildUnix")
workingDir("./build/libs")
dependsOn("buildUnix")
commandLine("mv","watchercli","/usr/bin/watchercli")
}
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"attempts" : 5, "link" : [], "refreshRate" : 60, "work" : []}
7 changes: 7 additions & 0 deletions deamon/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ task<Exec>("testUnix") {
commandLine("./watcher")
}

task<Exec>("testInstallUnix") {
dependsOn("buildUnix")
workingDir("./build/libs")
dependsOn("buildUnix")
commandLine("mv","watcher","/usr/bin/watcher")
}

val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions {
jvmTarget = "1.8"
Expand Down
12 changes: 6 additions & 6 deletions deamon/src/main/kotlin/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class Utils {
} else {
val jarPath = File(getCleanPath())
if (jarPath.canWrite()) {
println("Cannot acces /etc/processwatcher. Writing instead to '${jarPath.path}'")
println("Cannot acces /usr/share/processwatcher/. Writing instead to '${jarPath.path}'")
jarPath.path
} else {
val local = File("")
println("Cannot acces /etc/processwatcher. Writing instead to '${local.path}'")
local.path
val local = System.getProperty("user.dir")
println("Cannot acces ${jarPath}. Writing instead to '${local}'")
local
}
}
} else {
Expand All @@ -43,8 +43,8 @@ class Utils {
if (jarPath.canWrite()) {
jarPath.path
} else {
val local = File("")
local.path
val local = System.getProperty("user.dir")
local
}
}
} else {
Expand Down
67 changes: 61 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,71 @@
#!/bin/bash
function oldversion() {
OLDVERSION=false
if test -f "watcher"; then
OLDVERSION=true
fi
if test -f "watchercli"; then
OLDVERSION=true
fi
}

function checkjava() {
if type -p java; then
echo found java executable in PATH
_java=java
elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
echo Found java executable in JAVA_HOME
_java="$JAVA_HOME/bin/java"
else
echo "No java executable found!"
echo "Please install java >= 8 first"
exit
fi

if [[ "$_java" ]]; then
Version=$($_java -version 2>&1 | sed -E -n 's/.* version "([^.-]*).*"/\1/p' | cut -d' ' -f1)
echo Detect java Version "$Version"
if [ "$Version" -ge 8 ]; then
echo "Java version check oK"
else
echo "No java 8 or higher found"
echo "Please install java >= 8 first"
exit
fi
fi
}


if [ "$EUID" -ne 0 ]
then echo "Bitte führen sie das script als root aus!"
exit
fi

checkjava
cd /usr/bin/
if test -f "watcher"; then
rm watcher
fi
if test -f "watchercli"; then
rm watchercli
oldversion
if [ $OLDVERSION == true ]; then
echo "Detect an processWatcher Version!"
echo "Do you want to perform an update?[Y/N]"
read input
if [ "$input" == "Y" ] || [ "$input" == "y" ]; then
echo "Update ProcessWatcher"
if test -f "watcher"; then
rm watcher
fi
if test -f "watchercli"; then
rm watchercli
fi
elif [ "$input" == "N" ] || [ "$input" == "n" ]; then
echo "Nothing to Do!"
echo "exit"
exit
else
echo "No Valid Input!"
echo "exit"
exit
fi
fi

curl -s https://api.github.com/repos/Jonbeckas/processWatcher/releases/latest \
| grep "watcher" \
| cut -d : -f 2,3 \
Expand Down

0 comments on commit 6686335

Please sign in to comment.