ralbright Posted August 5, 2019 Posted August 5, 2019 Is it possible to have this setup to run as a service in Linux on Debian? Would certainly make some things easier on my end.
Bumbershoot Posted August 5, 2019 Posted August 5, 2019 Yes, it is. I believe the install script inserts a command into the '/etc/rc.local' file to start NodeLink. I use 'systemctl' to start/stop/restart NodeLink on an RPi running Stretch (which is a Debian variant). Here's what my 'nodelink.service' file looks link in '/etc/systemd/system': [UNIT] Description=NodeLink Server Documentation=http://automationshack.com/nodelink.html Requires=network-online.target After=network-online.target [Service] Type=simple ExecStartPre=/bin/sleep 10 ExecStart=/usr/bin/mono /home/pi/Nodelink/NodeLink.exe Restart=always User=pi [Install] WantedBy=multi-user.target Here's a post I wrote describing this technique for managing a WeatherFlow node server some time ago. The process for NodeLink is essentially identical, just substitute 'nodelink' for 'weatherflow' and use the 'nodelink.service' file above instead of the 'weatherflow.service' file described in the post.
ralbright Posted August 5, 2019 Author Posted August 5, 2019 I copied your nodelink.service file and placed it where you stated. I did have to change the ExecStart location, as the install script for NodeLink apparently installs to /home/pi/node/NodeLink.exe. When I issue the command sudo systemctl status nodelink. I get the following: nodelink.service Loaded: loaded (/etc/systemd/system/nodelink.service; enabled; vendor preset: enabled) Active: activating (start-pre) since Mon 2019-08-05 06:14:11 PDT; 4s ago Process: 3011 ExecStart=/usr/bin/mono /home/pi/node/NodeLink.exe (code=exited, status=1/FAILURE) Main PID: 3011 (code=exited, status=1/FAILURE); Control PID: 3020 (sleep) Tasks: 1 (limit: 19660) CGroup: /system.slice/nodelink.service └─control └─3020 /bin/sleep 10 Aug 05 06:14:11 polyglot systemd[1]: nodelink.service: Service hold-off time over, scheduling restart. Aug 05 06:14:11 polyglot systemd[1]: Stopped nodelink.service. Aug 05 06:14:11 polyglot systemd[1]: Starting nodelink.service... And this keeps repeating over and over... I am likely missing something REALLY simple here.
Bumbershoot Posted August 5, 2019 Posted August 5, 2019 Did you issue the command: 'sudo systemctl enable nodelink' prior to starting it? EDIT: Did you also edit the "User=pi" line of the 'nodelink.system' file to reflect the correct username that you used to install Nodelink?
ralbright Posted August 5, 2019 Author Posted August 5, 2019 8 hours ago, Bumbershoot said: Did you issue the command: 'sudo systemctl enable nodelink' prior to starting it? EDIT: Did you also edit the "User=pi" line of the 'nodelink.system' file to reflect the correct username that you used to install Nodelink? Yes and yes. The user I created in Debian 9 was named 'pi'
ralbright Posted August 5, 2019 Author Posted August 5, 2019 8 hours ago, Bumbershoot said: Did you issue the command: 'sudo systemctl enable nodelink' prior to starting it? EDIT: Did you also edit the "User=pi" line of the 'nodelink.system' file to reflect the correct username that you used to install Nodelink? So I just ran the command /usr/bin/mono /home/pi/node/NodeLink.exe and I get the following: Unhandled Exception: System.UnauthorizedAccessException: Access to the path "/home/pi/node/config-bak.xml" or "/home/pi/node/config.xml" is denied. at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) [0x001c4] in <8f2c484307284b51944a1a13a14c0266>:0 at NodeLink.xmlConfig.LoadXML () [0x000c3] in <b05e769338f042a5be8cbddc43419363>:0 at j.j () [0x0027a] in <b05e769338f042a5be8cbddc43419363>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.UnauthorizedAccessException: Access to the path "/home/pi/node/config-bak.xml" or "/home/pi/node/config.xml" is denied. at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) [0x001c4] in <8f2c484307284b51944a1a13a14c0266>:0 at NodeLink.xmlConfig.LoadXML () [0x000c3] in <b05e769338f042a5be8cbddc43419363>:0 at j.j () [0x0027a] in <b05e769338f042a5be8cbddc43419363>:0 I am guessing I need to change the permissions. So I did a chmod -R 777 to /home/pi/node. Then I ran sudo systemctl enable nodelink, then sudo systemctl start nodelink. That seems to have done the trick. It would likely be a good thing to have the service run as part of the install script.
Bumbershoot Posted August 5, 2019 Posted August 5, 2019 I believe the install script does it differently by inserting a command into '/etc/rc.local' instead of using the systemd framework. Check to see if you have NodeLink specified to start in '/etc/rc.local'. Either way, I'm glad you got it going. NodeLink is a terrific bit of software.
ralbright Posted August 5, 2019 Author Posted August 5, 2019 9 minutes ago, Bumbershoot said: I believe the install script does it differently by inserting a command into '/etc/rc.local' instead of using the systemd framework. Check to see if you have NodeLink specified to start in '/etc/rc.local'. Either way, I'm glad you got it going. NodeLink is a terrific bit of software. Yes it is, for the last long while I have been running it in Windows, and it would get closed and had trouble restarting it at times during reboots. So with Polyglot, (and the upcoming Polisy), I decided to set up a Hyper-V virtual machine for Polyglot and figured it would be a good idea to get NodeLink on the same VM. Thank you for your help. (Hyper-V should restart the machines automatically on reboots so that should be helpful in keeping all of this working.) Time will tell though.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.