dyne / dowse

The Awareness Hub for the Internet of Things
http://dowse.eu
159 stars 17 forks source link

start.sh failing to start redis #24

Closed cyphunk closed 7 years ago

cyphunk commented 7 years ago

On a Raspberry Pi with Devuan 1.0.0-beta dowse-start fails to connect to a local redis server. Should this be configured elsewhere?

Here is a set -x log from dowse-start

dowse@devuan:~$ zsh
This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~).  This function can help you with a few settings that should
make your use of the shell easier.

You can:

(q)  Quit and do nothing.  The function will be run again next time.

(0)  Exit, creating the file ~/.zshrc containing just a comment.
     That will prevent this function being run again.

(1)  Continue to the main menu.

(2)  Populate your ~/.zshrc with the configuration recommended
     by the system administrator and exit (you will need to edit
     the file by hand, if so desired).

--- Type one of the keys in parentheses ---

Aborting.
The function will be run again next time.  To prevent this, execute:
  touch ~/.zshrc
devuan% cd dowse
devuan% source dowse
 (*) Dowse CLI 0.9 - local area network rabdomancy

 Copyright (C) 2012-2016 Dyne.org Foundation, License GNU GPL v3+
 This is free software: you are free to change and redistribute it
 For more informations see http://www.dyne.org/software/dowse

  .  loading configuration from /etc/dowse/settings
 (*) 1 ipv4 connected devices found
  .   eth0 192.168.44.107/24
192.168.44.230/24
 (*) 1 ipv6 connected devices found
  .   eth0 fe80::ba27:ebff:fe2b:6032/64
  .  eth0 192.168.44.107 # detected network config
  .  checking requirements to run dowse...
  .  daemons running as user and group dowse:dowse
  .  all requirements in place
devuan% set -x                                                                                                                                                                 Dowse
devuan% dowse-start                                                                                                                                                            Dowse
+zsh:4> dowse-start
+dowse-start:2> fn dowse-start
+fn:1> fun=dowse-start
+fn:2> req=( )
+fn:3> freq=( )
+fn:4> func dowse-start
+func:1> [[ 0 == 1 ]]
+func:2> return 0
+dowse-start:6> [[+dowse-start:6> getpid redis-server
+getpid:1> fn getpid redis-server
+fn:1> fun='getpid redis-server'
+fn:2> req=( )
+fn:3> freq=( )
+fn:4> func 'getpid redis-server'
+func:1> [[ 0 == 1 ]]
+func:2> return 0
+getpid:2> _daemon=redis-server
+getpid:3> req=( _daemon )
+getpid:4> ckreq
+ckreq:1> err=0
+ckreq:2> v=_daemon
+ckreq:3> [[ redis-server ==  ]]
+ckreq:9> [[ 0 == 1 ]]
+ckreq:18> [[ 0 == 1 ]]
+ckreq:19> return 0
+getpid:6> unset _pid
+getpid:8> redis runtime
+getpid:8> print QUIT
+redis:2> _db=1
+redis:3> req=( _db )
+redis:4> ckreq
+ckreq:1> err=0
+ckreq:2> v=_db
+ckreq:3> [[ 1 ==  ]]
+ckreq:9> [[ 0 == 1 ]]
+ckreq:18> [[ 0 == 1 ]]
+ckreq:19> return 0
+redis:6> launch redis-cli -n 1 --raw
+redis:6> cat
+launch:1> fn launch redis-cli -n 1 --raw
+fn:1> fun='launch redis-cli -n 1 --raw'
+fn:2> req=( )
+fn:3> freq=( )
+fn:4> func 'launch redis-cli -n 1 --raw'
+func:1> [[ 0 == 1 ]]
+func:2> return 0
+launch:2> local '_cmd=redis-cli'
+launch:3> func 'command: redis-cli'
+func:1> [[ 0 == 1 ]]
+func:2> return 0
+launch:4> local '_path=/usr/local/dowse/bin/redis-cli'
+launch:5> req=( _cmd _path )
+launch:6> _freq=( /usr/local/dowse/bin/redis-cli )
+launch:7> ckreq
+ckreq:1> err=0
+ckreq:2> v=_cmd
+ckreq:3> [[ redis-cli ==  ]]
+ckreq:2> v=_path
+ckreq:3> [[ /usr/local/dowse/bin/redis-cli ==  ]]
+ckreq:9> [[ 0 == 1 ]]
+ckreq:18> [[ 0 == 1 ]]
+ckreq:19> return 0
+launch:9> local _ret
+launch:10> _rule=user
+launch:11> case user (user)
+launch:13> shift 1
+launch:14> func 'user launch: /usr/local/dowse/bin/redis-cli -n 1 --raw'
+func:1> [[ 0 == 1 ]]
+func:2> return 0
+launch:15> /usr/local/dowse/bin/redis-cli -n 1 --raw
Could not connect to Redis at 127.0.0.1:6379: Connection timed out
+launch:16> _ret=0
+launch:17> func 'redis-cli (user) returns 0'
+func:1> [[ 0 == 1 ]]
+func:2> return 0
+launch:18> return 0
+redis:7> [[ 0 == 0 ]]
+getpid:9> _pid=+getpid:9> _pid=+getpid:9> redis runtime
+getpid:9> print 'GET daemon-redis-server-pid'
+redis:2> _db=1
+redis:3> req=( _db )
+redis:4> ckreq
+ckreq:1> err=0
+ckreq:2> v=_db
+ckreq:3> [[ 1 ==  ]]
+ckreq:9> [[ 0 == 1 ]]
+ckreq:18> [[ 0 == 1 ]]
+ckreq:19> return 0
+redis:6> launch redis-cli -n 1 --raw
+redis:6> cat
+launch:1> fn launch redis-cli -n 1 --raw
+fn:1> fun='launch redis-cli -n 1 --raw'
+fn:2> req=( )
+fn:3> freq=( )
+fn:4> func 'launch redis-cli -n 1 --raw'
+func:1> [[ 0 == 1 ]]
+func:2> return 0
+launch:2> local '_cmd=redis-cli'
+launch:3> func 'command: redis-cli'
+func:1> [[ 0 == 1 ]]
+func:2> return 0
+launch:4> local '_path=/usr/local/dowse/bin/redis-cli'
+launch:5> req=( _cmd _path )
+launch:6> _freq=( /usr/local/dowse/bin/redis-cli )
+launch:7> ckreq
+ckreq:1> err=0
+ckreq:2> v=_cmd
+ckreq:3> [[ redis-cli ==  ]]
+ckreq:2> v=_path
+ckreq:3> [[ /usr/local/dowse/bin/redis-cli ==  ]]
+ckreq:9> [[ 0 == 1 ]]
+ckreq:18> [[ 0 == 1 ]]
+ckreq:19> return 0
+launch:9> local _ret
+launch:10> _rule=user
+launch:11> case user (user)
+launch:13> shift 1
+launch:14> func 'user launch: /usr/local/dowse/bin/redis-cli -n 1 --raw'
+func:1> [[ 0 == 1 ]]
+func:2> return 0
+launch:15> /usr/local/dowse/bin/redis-cli -n 1 --raw
packet_write_wait: Connection to 192.168.44.230: Broken pipe

A strace of the final redis-cli command:

...
open("/sys/devices/system/cpu/online", O_RDONLY|O_CLOEXEC) = 3
read(3, "0-3\n", 8192)                  = 4
close(3)                                = 0
mmap2(NULL, 4194304, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x76400000
ioctl(1, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
fcntl64(3, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK)  = 0
connect(3, {sa_family=AF_INET, sin_port=htons(6379), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
poll([{fd=3, events=POLLOUT}], 1, -1^CProcess 8163 detached
 <detached ...>

netstat:

dowse@devuan:~/dowse$ netstat -pan
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      1 127.0.0.1:45026         127.0.0.1:6379          SYN_SENT    8167/redis-cli
tcp        0      0 192.168.44.230:22       192.168.44.22:56194     ESTABLISHED -
tcp        0      0 192.168.44.230:22       192.168.44.1:37637      ESTABLISHED -
tcp        0    352 192.168.44.230:22       192.168.44.22:56195     ESTABLISHED -
tcp        0      0 192.168.44.107:22       192.168.44.1:54162      ESTABLISHED -
tcp        0      1 127.0.0.1:45025         127.0.0.1:6379          SYN_SENT    7921/redis-cli
tcp6       0      0 :::22                   :::*                    LISTEN      -
udp        0      0 0.0.0.0:12799           0.0.0.0:*                           -
udp        0      0 0.0.0.0:68              0.0.0.0:*                           -
udp6       0      0 :::42099                :::*                                -
jaromil commented 7 years ago

I think this is due to the fact we use a redis-cli connection to localhost to check if dowse is running. That's dirty, prints warnings and in this case it also seems to hang. There should be a better way to check if dowse is running...