Closed tobyweston closed 6 years ago
You should be able to locate the name of your network interface with ifconfig -a
, my ethernet is en0
but you're may differ.
As a workaround, you can substitute wlan0
with your network interface name (en0
above) in the start-XXX.sh
files. Note this is a unix bash script and may not work on Mac for example. Failing that, you can modify the scripts to just drop the JMX stuff:
#!/usr/bin/env bash
nohup java -Xmx512m -jar target/scala-2.12/temperature-machine-2.0.jar > temperature-machine.log 2>&1 &
echo "$!" > temperature-machine.pid
echo "Started your temperature-machine, redirecting output to temperature-machine.log, PID stored in temperature-machine.pid"
To fix this properly, we should check for the existence of network interfaces in some sort of sequence (eth0
then wlan0
?) and setup JMX if found, bypass JMX otherwise.
The current scripts use the following to assign a value to IP
, then uses it later on:
IP=$( ifconfig wlan0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}' )
But we could do something like this.
grep "wlan0" /proc/net/dev
in the script:
#!/bin/bash
WLAN=`grep "eth0:\|wlan0" /proc/net/dev`
if [ -n "$WLAN" ] ; then
JMX_OPTS="-D..."
else
JMX_OPTS=""
fi
ifconfig
seems to have changed it's output in recent kernels, so grep'ing inet addr
doesn't seem to work of 4.9.58. Might need something like this instead.
ip -f inet addr show wlan0 | grep -Po 'inet \K[\d.]+'
On 4.9.58:
$ ifconfig
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.1.26 netmask 255.255.255.0 broadcast 10.0.1.255
On 4.1.19:
$ ifconfig
wlan0 Link encap:Ethernet HWaddr 00:e0:4d:02:1d:f8
inet addr:10.0.1.35 Bcast:10.0.1.255 Mask:255.255.255.0
The ip -f
command works on both.
The
start.sh
,start-client.sh
andstart-server.sh
script is geared up for wireless connections.When the server starts up, it attempts to get the IP address of of the machine so you can monitor stats via the JMX console.
It does this with the following line:
If you don't have a
wlan0
configured, this won't work and you'll get an error similar to the following: