# A sample systemd service file for lnd running with a bitcoind service. [Unit] Description=Lightning Network Daemon # Make sure lnd starts after bitcoind is ready Requires=bitcoind.service After=bitcoind.service [Service] ExecStart=/usr/local/bin/lnd ExecStop=/usr/local/bin/lncli stop # Replace these with the user:group that will run lnd User=bitcoin Group=bitcoin # Try restarting lnd if it stops due to a failure. lnd exits with 0 after an # OS signal or `lncli stop`, with 1 on a critical error, and with a distinct # code when a health check gives up: 10 chain backend, 11 disk space, 12 TLS # certificate, 13 tor connection, 14 remote signer, 15 leader status. A health # check code always names the real cause, but a failure can surface elsewhere # before the check gives up and then lnd exits with 1 instead. A restart cannot # fix some of these, such as low disk space. Whether lnd should stay down in # that case is an operator decision, so uncomment and adjust the # RestartPreventExitStatus line below to make it. Restart=on-failure RestartSec=60 #RestartPreventExitStatus=11 # Type=notify is required for lnd to notify systemd when it is ready Type=notify # An extended timeout period is needed to allow for database compaction # and other time intensive operations during startup. We also extend the # stop timeout to ensure graceful shutdowns of lnd. TimeoutStartSec=1200 TimeoutStopSec=3600 # Hardening Measures #################### # Mount /usr, /boot/ and /etc read-only for the process. ProtectSystem=full # Disallow the process and all of its children to gain # new privileges through execve(). NoNewPrivileges=true # Use a new /dev namespace only populated with API pseudo devices # such as /dev/null, /dev/zero and /dev/random. PrivateDevices=true # Deny the creation of writable and executable memory mappings. MemoryDenyWriteExecute=true [Install] WantedBy=multi-user.target