storj-archived/storjshare-daemon

Daemon config file is not parsed on startup

akardes opened this issue · 6 comments

Package Versions

Replace the values below using the output from storjshare --version.

daemon: 5.2.0, core: 8.4.2, protocol: 1.2.0

Replace the values below using the output from node --version.

v6.12.0

Expected Behavior

The documentation tells that "so the simplest way to change the daemon's behavior is to create a file at $HOME/.config/storjshare/config containing the following:...".
So I created /root/.config/storjshare/config/daemon.config.json, modified values but the daemon does not actually parse this file on startup.

Actual Behavior

Changes to any of the daemon config parameters gets ignored.

Steps to Reproduce

  1. Create docker image from dockerfiles/storjshare-daemon-ubuntu.dockerfile.
  2. Take the config file from example/daemon.config.json
  3. Change daemonRpcPort to 45014
{
  // Bind Dnode RPC server to this port
  "daemonRpcPort": 45014,
  // Interface to bind Dnode RPC server, if your host is public, be sure to
  // leave this as "127.0.0.1" to prevent others from controlling your nodes
  // You can set this to a public address if you'd like to control your shares
  // remotely, however you must secure access on your own - you have been
  // warned
  "daemonRpcAddress": "0.0.0.0",
  // Path to write daemon log file to disk, leave blank to default to:
  // $HOME/.config/storjshare/logs/daemon.log
  "daemonLogFilePath": "",
  // Determines how much detail is shown in the log:
  // 4 - DEBUG | 3 - INFO | 2 - WARN | 1 - ERROR | 0 - SILENT
  "daemonLogVerbosity": 4
}
  1. Run the docker container, mounting the config file in the suggested directory:
docker run -it --rm \
    -v ${path-to-my-file}/daemon.config.json:/root/.config/storjshare/configs/daemon.config.json:z \
    storjshare-daemon:latest \
    bash
  1. Verify that the file is mounted in the right location:
root@a8ca2b88d9f6:/# cat /root/.config/storjshare/configs/daemon.config.json
{
  // Bind Dnode RPC server to this port
  "daemonRpcPort": 45014,
  // Interface to bind Dnode RPC server, if your host is public, be sure to
  // leave this as "127.0.0.1" to prevent others from controlling your nodes
  // You can set this to a public address if you'd like to control your shares
  // remotely, however you must secure access on your own - you have been
  // warned
  "daemonRpcAddress": "0.0.0.0",
  // Path to write daemon log file to disk, leave blank to default to:
  // $HOME/.config/storjshare/logs/daemon.log
  "daemonLogFilePath": "",
  // Determines how much detail is shown in the log:
  // 4 - DEBUG | 3 - INFO | 2 - WARN | 1 - ERROR | 0 - SILENT
  "daemonLogVerbosity": 4
}
  1. Start the daemon and observe that it responds on the default port instead of the port from the config file:
root@a8ca2b88d9f6:/# storjshare daemon 

  * starting daemon in background
root@a8ca2b88d9f6:/# storjshare status -r 127.0.0.1:45015

┌─────────────────────────────────────────────┬─────────┬──────────┬──────────┬─────────┬───────────────┬─────────┬──────────┬───────────┬──────────────┐
│ Share                                       │ Status  │ Uptime   │ Restarts │ Peers   │ Allocs        │ Delta   │ Port     │ Shared    │ Bridges      │
└─────────────────────────────────────────────┴─────────┴──────────┴──────────┴─────────┴───────────────┴─────────┴──────────┴───────────┴──────────────┘

root@a8ca2b88d9f6:/# storjshare status -r 127.0.0.1:45014

  daemon is not running, try: storjshare daemon

I think the problem is running that with files from the root home. I am not totally sure about that, but i ran into similar problems as i tried to do Storj tasks as root.
Can you try it without having these files in the root home?

No dice.
I created a user with it's own home directory and chowned it accordingly, by appending this to the Dockerfile...

RUN mkdir -p /home/storj
RUN groupadd -r storj &&\
    useradd -r -g storj -d /home/storj -c "storj user" storj
ENV HOME=/home/storj
RUN chown -R storj:storj $HOME
USER storj

I even chowned the config file on the host with the same uid:gid to make sure the permissions are ok in the container after mounting:

storj@storjshare-daemon:/$ ls -al /home/storj/.config/storjshare/configs/
total 4
drwxr-xr-x. 2 storj storj  32 Nov 17 22:58 .
drwxr-xr-x. 5 storj storj  47 Nov 17 22:58 ..
-rw-r--r--. 1 storj storj 707 Nov 17 21:52 daemon.config.json

I confirmed that it is creating the log file in that new user's directory structure:

storj@storjshare-daemon:/$ ls -al /home/storj/.config/storjshare/logs/   
total 0
drwxr-xr-x. 2 storj storj 24 Nov 17 22:58 .
drwxr-xr-x. 5 storj storj 47 Nov 17 22:58 ..
-rw-r--r--. 1 storj storj  0 Nov 17 22:58 daemon.log

Process running as the right user:

storj@storjshare-daemon:/$ ps auxww
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
storj        1  0.3  0.3 917308 61324 ?        Ssl  22:58   0:01 node /usr/bin/storjshare daemon --foreground
storj       12  0.2  0.3 955284 54264 ?        Sl   22:58   0:00 node /usr/lib/node_modules/storjshare-daemon/bin/storjshare-daemon.js --foreground

... but still, I get the same results.
To me it looks like the config file is not parsed.
None of the changed parameters are in effect. I have no experience in node, so I can't tell from the code if I'm putting the file in the correct path and with the correct filename. Just trusting the documentation here.

Did you take a look at your daemon.log file?
I will try to reproduce your steps later today!

It is empty.

[root@mogwai storjshare]# docker run -it --user storj --rm -v /docker_configs/storjshare/daemon.config.json:/home/storj/.config/storjshare/configs/daemon.config.json:z storjshare-daemon:non-root bash
storj@4d4285000670:/$ storjshare daemon

  * starting daemon in background
storj@4d4285000670:/$ 
storj@4d4285000670:/$ cat /home/storj/.config/storjshare/logs/daemon.log            
storj@4d4285000670:/$ 
storj@4d4285000670:/$ cat /home/storj/.config/storjshare/configs/daemon.config.json 
{
  // Bind Dnode RPC server to this port
  "daemonRpcPort": 45014,
  // Interface to bind Dnode RPC server, if your host is public, be sure to
  // leave this as "127.0.0.1" to prevent others from controlling your nodes
  // You can set this to a public address if you'd like to control your shares
  // remotely, however you must secure access on your own - you have been
  // warned
  "daemonRpcAddress": "0.0.0.0",
  // Path to write daemon log file to disk, leave blank to default to:
  // $HOME/.config/storjshare/logs/daemon.log
  "daemonLogFilePath": "",
  // Determines how much detail is shown in the log:
  // 4 - DEBUG | 3 - INFO | 2 - WARN | 1 - ERROR | 0 - SILENT
  "daemonLogVerbosity": 4
}
storj@4d4285000670:/$ ps auxww
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
storj        1  0.0  0.0  18232  3236 ?        Ss   17:55   0:00 bash
storj       25  0.6  0.4 954116 67952 ?        Ssl  17:56   0:00 /usr/bin/node /usr/lib/node_modules/storjshare-daemon/bin/storjshare-daemon.js
storj       37  0.0  0.0  34428  2780 ?        R+   17:58   0:00 ps auxww

Hello,
I'm using oreandawe/strojshare-cli docker and I have roughly the same issue:

  • config file in /root/.config/storjshare/configs/config.json (or any name finishing by .json) is not (really) taken into account
  • config file in /root/.config/storjshare/config is not (really) taken into account

By really, I mean that changing log path for example is not working. But changing daemonRpcAddress by 0.0.0.0 make the daemon crash (without logs)
And I've got no logs from daemon (but I have from client).

Changing 127.0.0.1 by 0.0.0.0 in /usr/lib/node_modules/storjshare-daemon/lib/config/daemon.js and doing a restart is working (daemon listen to anybody, which is interesting if you want to access to it from other containers for Storj Dash/Stat/Board for example)

👋 Hey! Thanks for this contribution. Apologies for the delay in responding!

We've decided to rearchitect Storj, so that we can scale better. You can read more about this decision here. This means that we are entirely focused on v3 at the moment, in the storj/storj repository. Our white paper for v3 is coming very, very soon - follow along on the blog and in our Rocketchat.

As this repository is part of the v2 network, we're no longer maintaining this repository. I am going to close this for now. If you have any questions, I encourage you to jump on Rocketchat and ask them there. Thanks!