Giter Club home page Giter Club logo

loki-launcher's Introduction

        .o0l.
       ;kNMNo.
     ;kNMMXd'
   ;kNMMXd'                 .ld:             ,ldxkkkdl,.     'dd;     ,odl.  ;dd
 ;kNMMXo.  'ol.             ,KMx.          :ONXkollokXN0c.   cNMo   .dNNx'   dMW
dNMMM0,   ;KMMXo.           ,KMx.        .oNNx'      .dNWx.  :NMo .cKWk;     dMW
'dXMMNk;  .;ONMMXo'         ,KMx.        :NMx.         oWWl  cNWd;ON0:.      oMW
  'dXMMNk;.  ;kNMMXd'       ,KMx.        lWWl          :NMd  cNMNNMWd.       dMW
    'dXMMNk;.  ;kNMMXd'     ,KMx.        :NMx.         oWWl  cNMKolKWO,      dMW
      .oXMMK;   ,0MMMNd.    ,KMx.        .dNNx'      .dNWx.  cNMo  .dNNd.    dMW
        .lo'  'dXMMNk;.     ,KMXxdddddl.   :ONNkollokXN0c.   cNMo    ;OWKl.  dMW
            'dXMMNk;        .lddddddddo.     ,ldxkkkdl,.     'od,     .cdo;  ;dd
          'dXMMNk;
         .oNMNk;             L A U N C H E R
          .l0l.

Requirements

  • nodejs versions 8.x to 12.x are supported
  • npm usually installed with nodejs (only for distribution and easy install of this software, we do not use ANY external NPMs for security reasons)
  • Linux (though macos does works and Windows kind of works)
  • xz (xz-utils apt package) to be able to download and extract updated Linux binaries
  • setcap (apt: libcap2-bin, rpm: libcap) to be enable lokinet to not need to run as root on Linux

Why use the launcher over DEBs

The goal of the launcher is to make it easier to run a service node, however the DEBs installation and upgrade process can be much easier if you're running a debian-based OS. However we do have some additional advantages:

  • Safer, we have additional checks in configuration, like to make sure you don't create port conflicts. We also have other checks that can detect unwanted patterns of behavior between apps and be able to take action
  • Easier config management, one config file to manage all 3 binaries, also reduces the chance of you having to resolve config conflicts during upgrades
  • Firewall Notification, lets you know if you're blocking any required ports. DEBs will open them in ufw but this won't help if you're using an different or external firewall.
  • NAT support, Launcher automatically configures your outgoing interface and public IP. DEBs you have to manually set up your network interface and public ip. Neither will help you set up port forwarding though.
  • Prequal tool, know for sure your situation meets our minimum requirements
  • Easy to downgrade path: if an upgrade is causing you problems, you can manually pull older releases off github and replace the binaries in /opt/loki-launcher/bin and simply restart the launcher with the older binary until your node is stable.
  • Diveristy of the network, in the highly unlikely event that Debian ever gets a serious bug, we want the service node network to be diverse enough to not be largely effective. Being able to support multiple operating systems is good for the Loki ecosystem.
  • Robust distribution system: Launcher relies on Microsoft/GitHub infrastructure, the DEBs are ran by our developer on his server. You could argue Microsoft/GitHub has more people keeping an eye on security and availability of their system. (And while we use NPM to distribute loki-launcher we do not use any NPM modules in this project)
  • Interactive client sessions, so you don't have lokid start up delays for each command you want to run
  • Unified subsystem reporting, get the status or versions of all 3 subsystems (blockchain, storage, network) from one command

Launcher is maintained at cost of the Loki Foundation and if it's not found to be of use, maybe unfunded. Please consider supporting this great tool by using it.

How to do a fresh service node install

This will use npm to install the launcher

sudo npm install -g loki-launcher

This will create any needed directories and make sure everything has the proper permissions to run as a specified user such as snode in this example

sudo loki-launcher set-perms snode

Now make sure sure you running the following commands as the user specified or you may run into permission problems (EPERM).

After it's installed, you can ask to prequalify your server to be a service node

loki-launcher prequal

you can also ask it to download the Loki binaries if you don't already have them

loki-launcher download-binaries

How to use without systemd

loki-launcher start

Running it once should start the suite of services into the background or give you a message why it can't. This isn't recommended for long term uses as there is nothing to restart launcher if it dies/exits.

Running loki-launcher client, will give you an interactive terminal to lokid (the copy running from the current directory if you have multiple). exit will stop your service node. If you just want to exit the interactive terminal, please use ctrl-c.

You can pass most command line parameters that you would give to lokid to loki-launcher start

You can make a launcher config file in /etc/loki-launcher/launcher.ini and change various settings, Check our wiki for details on options.

How to keep the launcher up to date

Update your launcher without systemd

Stop your service node if it's running (you can use loki-launcher status to check)

loki-launcher stop

Update the launcher

sudo npm install -g loki-launcher

And be sure to make sure you restart your service node (if it's staked) by

loki-launcher start

Get the latest Loki software versions

loki-launcher download-binaries

And be sure to make sure you restart your service node (if it's staked) by

loki-launcher start

Other

upgrading from lokid 3.0.6 with systemd to use the launcher

Popular linux distribution instructions to install NodeJS

CentOS NodeJS installation:

curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -

Ubuntu/Debian NodeJS installation:

curl -sL https://deb.nodesource.com/setup_12.x | sudo bash -

then

sudo apt-get install -y nodejs

Software the launcher manages

To get the required software you can run loki-launcher download-binaries and they will be placed in /opt/loki-launcher/bin

or

You can download the loki binaries (faster) from each above page's release section

or

You can build from source. Make sure you select the correct repos/branches/versions as not all versions will work with each other.

And if you don't have the dependencies to build from source check out contrib/dependency_helper/

Release Notes

Changelog items are now available here

For more indepth details, be sure to check out our weekly dev reports

loki-launcher's People

Contributors

doy-lee avatar ewhal avatar neuroscr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

loki-launcher's Issues

client connecting to sudo ran start

located launcher daemon at 14764
trying to connect to /opt/loki-launcher/var/launcher.socket
error { Error: connect EACCES /opt/loki-launcher/var/launcher.socket
    at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
  errno: 'EACCES',
  code: 'EACCES',
  syscall: 'connect',
  address: '/opt/loki-launcher/var/launcher.socket' }

snbench.js

how prepare is your environment to be a snode?

building lokid fails

 ---> Using cache
 ---> e69255d861f7
Step 45/77 : COPY src/loki .
 ---> Using cache
 ---> b4125b7c9a26
Step 46/77 : ENV USE_SINGLE_BUILDDIR=1
 ---> Using cache
 ---> c0302cbce2d4
Step 47/77 : ARG NPROC
 ---> Using cache
 ---> 1f7331f66e91
Step 48/77 : RUN set -ex &&     git submodule init && git submodule update &&     rm -rf build &&     if [ -z "$NPROC" ] ;     then make -j$(nproc) release-static ;     else make -j$NPROC release-static ;     fi
 ---> Running in fc0af51dc515
Step 48/77 : RUN set -ex &&     git submodule init && git submodule update &&     rm -rf build &&     if [ -z "$NPROC" ] ;     then make -j$(nproc) release-static ;     else make -j$NPROC release-static ;     fi
 ---> Running in fc0af51dc515
+ git submodule init
fatal: Not a git repository (or any of the parent directories): .git

I think it might be using the parent .git/modules or something similar.
Initializing these modules manually and commenting out git submodule init && git submodule update && \ makes it start compiling loki

run prequal when lokid is running

lokinet launcher version 0.8 registered
Starting open port check on configured RPC port: 22023
events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::22023
    at Server.setupListenHandle [as _listen2] (net.js:1279:14)
    at listenInCluster (net.js:1327:12)
    at Server.listen (net.js:1414:7)
    at Object.serveTCP (/usr/lib/node_modules/loki-launcher/lets_tcp.js:464:12)
    at portTest (/usr/lib/node_modules/loki-launcher/modes/prequal.js:162:33)
    at module.exports (/usr/lib/node_modules/loki-launcher/modes/prequal.js:194:3)
    at Object.<anonymous> (/usr/lib/node_modules/loki-launcher/index.js:223:42)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
Emitted 'error' event at:
    at emitErrorNT (net.js:1306:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

Health check endpoint

Just a basic healthcheck endpoint e.g "/healthz" that just returns 200 {"status": "ok"} if everything is up and running

LokiKey says offline

@neuroscr

I came across something a bit odd regarding lokiKey,

When I stop Loki-launcher and then start it again, it show that the lokiKey has been found at ~/.loki........

Then after a couple seconds when I ask for status, it says it is offline,

image

To add to that it appears my config inside loki.conf is being ignored in regards to the rpc-bind-port that I have set inside it, tried putting the file in,

~/.loki
~/.loki/testnet/

same behaviour

Originally posted by @Fez29 in #34 (comment)

Version Flags

1. Version Flag

Current:

loki-launcher -v
loki-launcher --version

are unknown flags.

Desired:

Spit out versions

2. ASCII ART Version

Doesn't update the loki-launcher version

image

move multi-instance info out of this repo

mkdir a directory somewhere
if you want to use a different user per repo, then clone the repo to the user's home directory (this is safer than running them all as root per se)
replace X with the number for the instance or a name
git clone https://github.com/loki-project/loki-launcher.git loki-launcherX
cd loki-launcherX
touch launcher.ini
Example configuration: https://github.com/loki-project/loki-launcher/blob/master/launcher-docker.ini
Complete config guide here: https://lokidocs.com/ServiceNodes/launcherconfig/
var_path needs to be distinct per copy
We've determined the most basic INI file is:

      [launcher]
      var_path=/home/USER/loki-launcher/var
      [blockchain]
      1=1

the blockchain and 1=1 is a temporary hack for a past bug that is now confirmed fixed.

your systemd service file (/etc/systemd/system/[email protected]) could look like

[Unit]
Description=lokid service node
After=network-online.target

[Service]
Type=simple
User=%i
ExecStart=/home/%i/loki-launcher/index.js daemon-start --config-file=/home/%i/loki/%i.conf
Restart=always
RestartSec=30s

[Install]
WantedBy=multi-user.target

small scripts to make a bunch of launcher.ini

for i in seq 1 11;do
    launcher="/home/snode$i/loki-launcher/launcher.ini"
    cat <<EOT >> $launcher
      [launcher]
      var_path=/home/snode$i/loki-launcher/var
      [blockchain]
      1=1
  EOT    

done

then to use each individual copy (su to the correct user) go into the clone directory and use ./index.js instead of loki-launcher, i.e. ./index.js prequal or ./index.js status

sudo -H -u USER /home/USER/loki-launcher/index.js status

.bashrc suggestion: alias launcher-USER='sudo -H -u USER /home/USER/loki-launcher/index.js'

storage server <=> lokid communication breakdown detection

can we detect?

Nov 08 18:12:27 loki12 loki-storage[31601]: [2019-11-08 18:12:27.555] [info] [operator()] Successfully pinged Lokid
Nov 08 18:16:49 loki12 loki-storage[31601]: [2019-11-08 18:16:49.206] [critical] [operator()] Could not send blockchain request to Lokid
Nov 08 18:17:27 loki12 loki-storage[31601]: [2019-11-08 18:17:27.550] [info] [set_difficulty_history] Read PoW difficulty: 1
Nov 08 18:17:27 loki12 loki-storage[31601]: [2019-11-08 18:17:27.557] [info] [operator()] Successfully pinged Lokid
Nov 08 18:19:16 loki12 loki-storage[31601]: [2019-11-08 18:19:16.662] [critical] [operator()] Could not send blockchain request to Lokid```

"storageServer.version" is not owned by user creating the Loki Launcher

Describe the bug
"Permission denied" exception occurs when running lokid at the time Loki tries to start the storage server: Caught exception: Error: EACCES: permission denied, open '/opt/loki-launcher/var/storageServer.version'.

To Reproduce
Just follow the Service node Guide at https://lokidocs.com/ServiceNodes/SNFullGuide/#express-setup-guide. I am using Debian 9 and I am not sure if this affects other OS too.

To Solve
Change the ownership of the storageServer.version from root to the user running the Loki launcher (e.g. "snode").

Screenshots or Logs

Jul 23 08:48:46 debian index.js[451]: **************************************************************
Jul 23 08:48:46 debian index.js[451]: Outputting logs to /home/snode/.loki/storage/storage.logs
Jul 23 08:48:46 debian index.js[451]: [2019-07-23 08:48:46.113] [info] Loki Storage Server v1.0.2
Jul 23 08:48:46 debian index.js[451]:  git commit hash: 8ba5286
Jul 23 08:48:46 debian index.js[451]:  build time: 2019-07-15T07:54:30Z
Jul 23 08:48:46 debian index.js[451]: Caught exception: Error: EACCES: permission denied, open '/opt/loki-launcher/var/storageServer.version'
Jul 23 08:48:46 debian index.js[451]: fs.js:114
Jul 23 08:48:46 debian index.js[451]:     throw err;
Jul 23 08:48:46 debian index.js[451]:     ^
Jul 23 08:48:46 debian index.js[451]: Error: EACCES: permission denied, open 'launcher_exception.log'
Jul 23 08:48:46 debian index.js[451]:     at Object.openSync (fs.js:443:3)
Jul 23 08:48:46 debian index.js[451]:     at Object.writeFileSync (fs.js:1194:35)
Jul 23 08:48:46 debian index.js[451]:     at Object.appendFileSync (fs.js:1240:6)
Jul 23 08:48:46 debian index.js[451]:     at process.<anonymous> (/usr/lib/node_modules/loki-launcher/daemon.js:21:6)
Jul 23 08:48:46 debian index.js[451]:     at process.emit (events.js:198:13)
Jul 23 08:48:46 debian systemd[1]: lokid.service: Main process exited, code=exited, status=7/NOTRUNNING
Jul 23 08:48:50 debian systemd[1]: lokid.service: Unit entered failed state.
Jul 23 08:48:50 debian systemd[1]: lokid.service: Failed with result 'exit-code'.
Jul 23 08:49:21 debian systemd[1]: lokid.service: Service hold-off time over, scheduling restart.
Jul 23 08:49:21 debian systemd[1]: Stopped lokilauncher.

Additional Information (please complete the following information):

  • Operating System: Debian 9
  • Remote node
  • Version of Loki daemon: 4.0.3

After upgrading testnet node getting error complaining ini file is not defined

Existing instance on testnet running loki-launcher.

Steps taken:
1)
sudo npm i -g loki-launcher
2)
loki-launcher download-binaries --testnet
3)
loki-launcher status

Response:


~$ loki-launcher client
/usr/lib/node_modules/loki-launcher/config.js:160
const moneroDiskOptions = ini.iniToJSON(moneroDiskConfig.toString())
^

ReferenceError: ini is not defined
at loadBlockchainConfigFile (/usr/lib/node_modules/loki-launcher/config.js:160:33)
at precheckConfig (/usr/lib/node_modules/loki-launcher/config.js:210:3)
at Object.checkConfig [as check] (/usr/lib/node_modules/loki-launcher/config.js:437:3)
at Object. (/usr/lib/node_modules/loki-launcher/index.js:89:12)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)


I am passing testnet flags via ~/.loki/loki.conf

Please let me know if above is not sufficient and more details/logfiles etc are required or incorrect steps followed.

npm support

can we distro binaries with this?

also make sure the config never gets stomped...

user may use a homedir of /root

see what we would need to make this work without error:

lokinet launcher version 0.8 registered
setting permissions to pepe
user pepe uid is 1001 homedir is /root
fs.js:114
    throw err;
    ^

Error: ENOENT: no such file or directory, chown '/root/.loki'
    at Object.chownSync (fs.js:1090:3)
    at /usr/lib/node_modules/loki-launcher/modes/fix-perms.js:100:10
    at /usr/lib/node_modules/loki-launcher/uid.js:99:5
    at ChildProcess.exithandler (child_process.js:285:7)
    at ChildProcess.emit (events.js:198:13)
    at maybeClose (internal/child_process.js:982:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

Getting error on StorageServer when running loki-launcher start

STORAGE: Launching /opt/loki-launcher/bin/loki-storage 0.0.0.0 22021 --lokid-key /home/snode/.loki/key --data-dir /home/snode/.loki/storage --lokid-rpc-port 22023
Storage Server error: lmq-port command line option is not specified
Storage Server error:
Storage Server error: Usage:
Storage Server error: loki-storage
Storage Server error: <address> <port> [...]
Storage Server error: --data-dir arg
Storage Server error:
Storage Server error:
Storage Server error:
Storage Server error:
Storage Server error:
Storage Server error: Path to persistent data (defaults to
                           ~/.loki/storage)
  --config-file arg        Path to custom config file (defaults to
                           `storage-server.conf' inside --data-dir)
  --log-level arg          Log verbosity level, see Log Levels below for
Storage Server error: accepted values
  --lokid-rpc-ip arg       RPC IP on which the local Loki daemon is listening
                           (usually localhost)
  --lokid-rpc-port arg     RPC port on whic
Storage Server error: h the local Loki daemon is listening
  --lmq-port arg           Port used by LokiMQ
  --testnet                Start storage server in testnet mode
Storage Server error: --force-start            Ignore the initialisation ready check
  --bind-ip arg (=0.0.0.0) IP to which to bind the server
  -v [ --version ]         Print the version of this binary
  --help                   Shows this help message

  Log Levels:
    trace
    debug
    info
    warning
    error
    critical
StorageServer process exited with code 1 after 42ms
 stderr

I can't seem to start my loki node anymore with loki-launcher.

detect systemd usage

prequal, download-binaries, fix-perms needs a warning

fix-perms isn't so bad if it starts up again.
download-binaries will dead lock.

install.js (systemd integration options?)

proves they have nodejs installed

run as root
needs to detect where your nodejs is located (/usr/bin/env can do this)
should detect and modify systemd config to replace lokid with launcher

ExecStart=/home/snode/loki/lokid --non-interactive --service-node

in /etc/systemd/system/lokid.service
is systemd always in the same place on all distros?
check processlist for systemd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.