samyk / easel-driver

Easel driver for Linux, Mac, Windows, ARM, Raspberry Pi, Intel, FTDI, CH340, CH341, CP210x, FTDI clones, local, and remote access to GRBL-based CNC controllers
94 stars 24 forks source link

Service not resuming after reboot #22

Closed jackomyers closed 1 month ago

jackomyers commented 2 years ago

Firstly, I am way out of my depth here, my linux knowledge is akin to being able to order a beer in a forgeign country, so please forgive me if my ineptitude offends you.

I have installed the easel driver on several occasions and works fine once installed, however the problem lies in the fact that i cannot get the service to resume after a reboot without manually executing the "run.sh" file in the folder.

below is a copy of the output, admittedly not the complete transcript because output exceeds the limit of terminal (any other suggestions to get the full file are welcome), I have included from the beginning of some warnings that were thrown up during install:

Thank you in advance

Edit: I should also mention this is a clean install of raspbery pi Debian Bullseye released 04/04/22 from the imager software.

Now using node v12.19.0 (npm v6.14.8)
+ npm install
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated json3@3.3.2: Please use the native JSON object instead of JSON 3

> @serialport/bindings@2.0.8 install /home/pi/easel-driver/node_modules/@serialport/bindings
> prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=12.19.0 runtime=node arch=arm libc= platform=linux)
make: Entering directory '/home/pi/easel-driver/node_modules/@serialport/bindings/build'
  CXX(target) Release/obj.target/bindings/src/serialport.o
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Open(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:78:51: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
   78 |   uv_queue_work(uv_default_loop(), req, EIO_Open, (uv_after_work_cb)EIO_AfterOpen);
      |                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Update(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:135:53: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
  135 |   uv_queue_work(uv_default_loop(), req, EIO_Update, (uv_after_work_cb)EIO_AfterUpdate);
      |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Close(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:175:52: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
  175 |   uv_queue_work(uv_default_loop(), req, EIO_Close, (uv_after_work_cb)EIO_AfterClose);
      |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Flush(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:215:52: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
  215 |   uv_queue_work(uv_default_loop(), req, EIO_Flush, (uv_after_work_cb)EIO_AfterFlush);
      |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Set(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:270:50: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
  270 |   uv_queue_work(uv_default_loop(), req, EIO_Set, (uv_after_work_cb)EIO_AfterSet);
      |                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Get(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:314:50: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
  314 |   uv_queue_work(uv_default_loop(), req, EIO_Get, (uv_after_work_cb)EIO_AfterGet);
      |                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: In function ‘void EIO_AfterGet(uv_work_t*)’:
../src/serialport.cpp:329:96: warning: ‘bool v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
  329 |     results->Set(Nan::New<v8::String>("cts").ToLocalChecked(), Nan::New<v8::Boolean>(data->cts));
      |                                                                                                ^
In file included from /home/pi/.cache/node-gyp/12.19.0/include/node/v8-internal.h:14,
                 from /home/pi/.cache/node-gyp/12.19.0/include/node/v8.h:27,
                 from /home/pi/.cache/node-gyp/12.19.0/include/node/node.h:67,
                 from ../../../nan/nan.h:60,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.cache/node-gyp/12.19.0/include/node/v8.h:3499:22: note: declared here
 3499 |                 bool Set(Local<Value> key, Local<Value> value));
      |                      ^~~
/home/pi/.cache/node-gyp/12.19.0/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
  328 |   declarator __attribute__((deprecated(message)))
      |   ^~~~~~~~~~
../src/serialport.cpp:330:96: warning: ‘bool v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
  330 |     results->Set(Nan::New<v8::String>("dsr").ToLocalChecked(), Nan::New<v8::Boolean>(data->dsr));
      |                                                                                                ^
In file included from /home/pi/.cache/node-gyp/12.19.0/include/node/v8-internal.h:14,
                 from /home/pi/.cache/node-gyp/12.19.0/include/node/v8.h:27,
                 from /home/pi/.cache/node-gyp/12.19.0/include/node/node.h:67,
                 from ../../../nan/nan.h:60,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.cache/node-gyp/12.19.0/include/node/v8.h:3499:22: note: declared here
 3499 |                 bool Set(Local<Value> key, Local<Value> value));
      |                      ^~~
/home/pi/.cache/node-gyp/12.19.0/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
  328 |   declarator __attribute__((deprecated(message)))
      |   ^~~~~~~~~~
../src/serialport.cpp:331:96: warning: ‘bool v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
  331 |     results->Set(Nan::New<v8::String>("dcd").ToLocalChecked(), Nan::New<v8::Boolean>(data->dcd));
      |                                                                                                ^
In file included from /home/pi/.cache/node-gyp/12.19.0/include/node/v8-internal.h:14,
                 from /home/pi/.cache/node-gyp/12.19.0/include/node/v8.h:27,
                 from /home/pi/.cache/node-gyp/12.19.0/include/node/node.h:67,
                 from ../../../nan/nan.h:60,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.cache/node-gyp/12.19.0/include/node/v8.h:3499:22: note: declared here
 3499 |                 bool Set(Local<Value> key, Local<Value> value));
      |                      ^~~
/home/pi/.cache/node-gyp/12.19.0/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
  328 |   declarator __attribute__((deprecated(message)))
      |   ^~~~~~~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE GetBaudRate(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:363:58: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
  363 |   uv_queue_work(uv_default_loop(), req, EIO_GetBaudRate, (uv_after_work_cb)EIO_AfterGetBaudRate);
      |                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: In function ‘void EIO_AfterGetBaudRate(uv_work_t*)’:
../src/serialport.cpp:378:106: warning: ‘bool v8::Object::Set(v8::Local<v8::Value>, v8::Local<v8::Value>)’ is deprecated: Use maybe version [-Wdeprecated-declarations]
  378 |     results->Set(Nan::New<v8::String>("baudRate").ToLocalChecked(), Nan::New<v8::Integer>(data->baudRate));
      |                                                                                                          ^
In file included from /home/pi/.cache/node-gyp/12.19.0/include/node/v8-internal.h:14,
                 from /home/pi/.cache/node-gyp/12.19.0/include/node/v8.h:27,
                 from /home/pi/.cache/node-gyp/12.19.0/include/node/node.h:67,
                 from ../../../nan/nan.h:60,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.cache/node-gyp/12.19.0/include/node/v8.h:3499:22: note: declared here
 3499 |                 bool Set(Local<Value> key, Local<Value> value));
      |                      ^~~
/home/pi/.cache/node-gyp/12.19.0/include/node/v8config.h:328:3: note: in definition of macro ‘V8_DEPRECATED’
  328 |   declarator __attribute__((deprecated(message)))
      |   ^~~~~~~~~~
../src/serialport.cpp: In function ‘Nan::NAN_METHOD_RETURN_TYPE Drain(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/serialport.cpp:409:52: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
  409 |   uv_queue_work(uv_default_loop(), req, EIO_Drain, (uv_after_work_cb)EIO_AfterDrain);
      |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport.cpp: At global scope:
../src/serialport.cpp:430:28: warning: unnecessary parentheses in declaration of ‘ToParityEnum’ [-Wparentheses]
  430 | SerialPortParity NAN_INLINE(ToParityEnum(const v8::Local<v8::String>& v8str)) {
      |                            ^
../src/serialport.cpp:449:30: warning: unnecessary parentheses in declaration of ‘ToStopBitEnum’ [-Wparentheses]
  449 | SerialPortStopBits NAN_INLINE(ToStopBitEnum(double stopBits)) {
      |                              ^
In file included from ../../../nan/nan.h:60,
                 from ../src/./serialport.h:6,
                 from ../src/serialport.cpp:1:
/home/pi/.cache/node-gyp/12.19.0/include/node/node.h:727:7: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
  727 |       (node::addon_register_func) (regfunc),                          \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pi/.cache/node-gyp/12.19.0/include/node/node.h:761:3: note: in expansion of macro ‘NODE_MODULE_X’
  761 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
      |   ^~~~~~~~~~~~~
../src/serialport.cpp:483:1: note: in expansion of macro ‘NODE_MODULE’
  483 | NODE_MODULE(serialport, init);
      | ^~~~~~~~~~~
  CXX(target) Release/obj.target/bindings/src/serialport_unix.o
../src/serialport_unix.cpp: In function ‘int setup(int, OpenBaton*)’:
../src/serialport_unix.cpp:176:82: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 1005 [-Wformat-truncation=]
  176 |     snprintf(data->errorString, sizeof(data->errorString), "Error %s Cannot open %s", strerror(errno), data->path);
      |                                                                                  ^~
../src/serialport_unix.cpp:176:13: note: ‘snprintf’ output 20 or more bytes (assuming 1043) into a destination of size 1024
  176 |     snprintf(data->errorString, sizeof(data->errorString), "Error %s Cannot open %s", strerror(errno), data->path);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/serialport_unix.cpp: In function ‘void EIO_Open(uv_work_t*)’:
../src/serialport_unix.cpp:86:84: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 1003 [-Wformat-truncation=]
   86 |     snprintf(data->errorString, sizeof(data->errorString), "Error: %s, cannot open %s", strerror(errno), data->path);
      |                                                                                    ^~
../src/serialport_unix.cpp:86:13: note: ‘snprintf’ output 22 or more bytes (assuming 1045) into a destination of size 1024
   86 |     snprintf(data->errorString, sizeof(data->errorString), "Error: %s, cannot open %s", strerror(errno), data->path);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CXX(target) Release/obj.target/bindings/src/poller.o
  CXX(target) Release/obj.target/bindings/src/serialport_linux.o
  SOLINK_MODULE(target) Release/obj.target/bindings.node
  COPY Release/bindings.node
make: Leaving directory '/home/pi/easel-driver/node_modules/@serialport/bindings/build'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN Iris@0.3.21 No description
npm WARN Iris@0.3.21 No repository field.
npm WARN Iris@0.3.21 No license field.

added 174 packages from 856 contributors and audited 174 packages in 28.197s

5 packages are looking for funding
  run `npm fund` for details

found 14 vulnerabilities (7 low, 2 moderate, 4 high, 1 critical)
  run `npm audit fix` to fix them, or `npm audit` for details
+ echo \n\n\n

+ true
+ echo Almost done! Do you want Easel driver to run on startup (will install system service) [yn]: 
Almost done! Do you want Easel driver to run on startup (will install system service) [yn]: 
+ read yn
y
+ check_init
+ [ -d /run/systemd/system/ ]
+ SYSD=1
+ create_start_script
+ pwd
+ driverdir=/home/pi/easel-driver
+ touch /home/pi/easel-driver/run.sh
+ chmod +x /home/pi/easel-driver/run.sh
+ cat
+ install_service
+ [ 1 = 1 ]
+ touch /home/pi/easel-driver/EaselDriver.service
+ whoami
+ cat
+ sudo mv /home/pi/easel-driver/EaselDriver.service /etc/systemd/system/
+ sudo systemctl daemon-reload
+ sudo systemctl enable EaselDriver.service
+ break
+ screen -L -dmS easel node iris.js
+ sleep 3
+ echo \n\n\n

+ tail screenlog.0
+ echo \n\nDone! Easel driver running in background. Run `screen -r` to bring it to foreground.

Done! Easel driver running in background. Run `screen -r` to bring it to foreground.
samyk commented 2 years ago

Thanks for pasting, we'll want to see the entire output. You can rerun it by doing this, then pasting 'output.log' here (you can scp it or sftp it off the machine):

curl https://raw.githubusercontent.com/samyk/easel-driver/master/easel-driver.sh | sh -x > output.log
samyk commented 2 years ago

Also please include what you see in screen -r both before rebooting, and then after rebooting. Also please include the output of ~/easel-driver/screenlog.* AFTER the reboot assuming it's not working. Thanks

jackomyers commented 2 years ago

Thanks, I will get this posted as soon as I'm back in work tomorrow.

jackomyers commented 2 years ago

Im just running the code for the output log as you suggested but it would seem that i get some sort of output loop when it asks if I want the service to start on reboot (y/n). It doesn't do that without the > output.log string. Is this normal?

Also, the output, when opened in the Text Editor or Geany, doesnt seem to display the full code that is shown when running through the install prosesses, again is this to be expected?

Thanks in advance.

Reading package lists...
Building dependency tree...
Reading state information...
avrdude is already the newest version (6.3-20171130+svn1429-2+b1).
p7zip-full is already the newest version (16.02+dfsg-8).
screen is already the newest version (4.8.0-6).
The following package was automatically installed and is no longer required:
  libfuse2
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 24 not upgraded.

7-Zip [32] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,32 bits,4 CPUs LE)

Scanning the drive for archives:
1 file, 23567251 bytes (23 MiB)

Extracting archive: EaselDriver.pkg

WARNINGS:
There are data after the end of archive

--
Path = EaselDriver.pkg
Type = Xar
WARNINGS:
There are data after the end of archive
Physical Size = 23565481
Tail Size = 1770
SubType = pkg
Headers Size = 5083

Everything is Ok

Archives with Warnings: 1

Warnings: 1
Folders: 3
Files: 12
Size:       24998874
Compressed: 23567251
=> nvm is already installed in /home/pi/.config/nvm, trying to update using git

=> => Compressing and cleaning up git repository

=> nvm source string already in /home/pi/.bashrc
=> bash_completion source string already in /home/pi/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.config/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
nvm
Now using node v12.19.0 (npm v6.14.8)
Now using node v12.19.0 (npm v6.14.8)

> @serialport/bindings@2.0.8 install /home/pi/easel-driver/node_modules/@serialport/bindings
> prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild

make: Entering directory '/home/pi/easel-driver/node_modules/@serialport/bindings/build'
  CXX(target) Release/obj.target/bindings/src/serialport.o
  CXX(target) Release/obj.target/bindings/src/serialport_unix.o
  CXX(target) Release/obj.target/bindings/src/poller.o
  CXX(target) Release/obj.target/bindings/src/serialport_linux.o
  SOLINK_MODULE(target) Release/obj.target/bindings.node
  COPY Release/bindings.node
make: Leaving directory '/home/pi/easel-driver/node_modules/@serialport/bindings/build'
added 174 packages from 856 contributors and audited 174 packages in 36.063s

5 packages are looking for funding
  run `npm fund` for details

found 14 vulnerabilities (7 low, 2 moderate, 4 high, 1 critical)
  run `npm audit fix` to fix them, or `npm audit` for details

Almost done! Do you want Easel driver to run on startup (will install system service) [yn]: 
Please answer yes/no
Almost done! Do you want Easel driver to run on startup (will install system service) [yn]: 
Please answer yes/no
Almost done! Do you want Easel driver to run on startup (will install system service) [yn]: 
Please answer yes/no
Almost done! Do you want Easel driver to run on startup (will install system service) [yn]: 
Please answer yes/no
... (CONTINUES)
jackomyers commented 2 years ago

Ok, I'm not sure if you needed this but I managed to append the command to |$ tee output.log to included all standard and error output.

Again, this still causes a loop at the end... which, I believe because I have to ctrl+z out of, causes an interrupt to the install so screen -r says that there is nothing to resumed. I have had to append the output.log to include the output after the loop {attached} output.log

I have run the install without the output.log string to gain the screen -r information you requested {below}. BEFORE REBOOT:

2022-07-11T08:45:41.071Z iris.js [id=0] Starting Easel Driver 0.3.21
2022-07-11T08:45:41.077Z Machine [id=3] Resetting
2022-07-11T08:45:41.110Z iris.js [id=0] Listening on port 1438 for secure connections from easel.inventables.com:80 easel.inventables.com:443 easelstaging.inventables.com:80 easelstaging.inventables.com:443 easel.invinternal.com:443 easel-secure.inventables.com:443 easel-insecure.inventables.com:80
2022-07-11T08:45:41.117Z iris.js [id=0] Listening on port 1338 for connections from easel.inventables.com:80 easel.inventables.com:443 easelstaging.inventables.com:80 easelstaging.inventables.com:443 easel.invinternal.com:443 easel-secure.inventables.com:443 easel-insecure.inventables.com:80

AFTER REBOOT:

###@###:~ $ screen -r
There is no screen to be resumed.
###@###:~ $ 
jackomyers commented 11 months ago

Ok... a VERY late update to this but I managed to get to the bottom of the issue.

It turns out the the run.sh script was trying to redirect to a non existent NVM folder. I have had to manually edit the script after installation to the following:

. ~/.config/nvm/nvm.sh

This has solved all issues and the service starts on reboot. I dont know why this only seems to have been affecting a few users but this was a standard fresh install of raspberry pi.

Do you think the installation script needs to be edited to reflect the above or is this something that is more a localised issue?

Thanks

samyk commented 1 month ago

I think this is resolved by @rlancaste's #27 which is now merged to support different nvm paths.