Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which is the recommended distro for RPi3 #42

Closed
SummerWine opened this issue Jan 26, 2019 · 10 comments
Closed

Which is the recommended distro for RPi3 #42

SummerWine opened this issue Jan 26, 2019 · 10 comments
Labels

Comments

@SummerWine
Copy link

Which (minimal) distro should i use?

I tried Raspbian Stretch Lite (November 2018), but i am not able to get it working. Are there any missing packages?

After installation i used "apt-get update" and "apt-get upgrade" and then i followed your manual, but i got many errors (to many to post here).

Wich distro was succesfully tested?

Big Thanks.

@bpatrik
Copy link
Owner

bpatrik commented Jan 26, 2019

Hi,

Most likely you have a old node version (you can check it with node -v), make sure you have >=8, <=11. Recommended: node v10.
The default apt-get install node gives you an old version node.

Detailed instructions:

I'm using the official Raspbian Stretch Lite (https://www.raspberrypi.org/downloads/raspbian/) on my RP3.

Then install node:
This usually works: https://nodejs.org/en/download/package-manager/
Approximately, this should be the way of installing node:

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

You might need this one too, (but I had a reinstall a few weeks ago and it worked without it)

apt-get install build-essential  libkrb5-dev gcc g++

install

cd ~
wget https://github.com/bpatrik/pigallery2/releases/download/1.5.6/pigallery2.zip
unzip pigallery2.zip -d pigallery2
cd pigallery2
npm install

Note: if npm install fails because of errors like 'out of memory', you can try to rerun it. It makes some progress with every run.

Optionally I can recommend using nginx as load balancer for nodejs and certbot to have https.

Let me know if this helps.
I'm working on a more detailed installation guide, but that will take a while.

@SummerWine
Copy link
Author

SummerWine commented Jan 26, 2019

Thanks for your quick answer.

node -v = 10.15.0.0

Now i got a (successfull) installation and was able to start the service. I don't know why it worked. I used "sudo su" instead of sudo "command".

Sorry for the question, but what is the diffence between:

1.1.1-a Install from release
1.1.1-b Install from source
npm run build-release

Here are my errors:
Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.0.4/node-v64-linux-arm.tar.gz
node-pre-gyp WARN Pre-built binaries not found for sqlite3@4.0.4 and node@10.15.0 (node-v64 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp WARN Pre-built binaries not installable for sqlite3@4.0.4 and node@10.15.0 (node-v64 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error Connection closed while downloading tarball file

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.2/bcrypt_lib-v3.0.2-node-v64-linux-arm-glibc.tar.gz
node-pre-gyp WARN Pre-built binaries not found for bcrypt@3.0.2 and node@10.15.0 (node-v64 ABI, glibc) (falling back to source compile with node-gyp)
make: Entering directory '/home/pi/pigallery2/node_modules/bcrypt/build'
CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
../src/bcrypt_node.cc: In function âchar {anonymous}::ToCharVersion(v8::Localv8::String)â:
../src/bcrypt_node.cc:66:30: warning: âv8::String::Utf8Value::Utf8Value(v8::Localv8::Value)â is deprecated: Use Isolate version [-Wdeprecated-declarations]
String::Utf8Value value(str);

Further i got ffmpeg errors.

@bpatrik
Copy link
Owner

bpatrik commented Jan 26, 2019

Hi,

1.1.1-a Install from release way of installation is the recommended.
You download a pre compiled version of the app. It should be the faster way.
Also release versions are somewhat more stable.

1.1.1-b Install from source way is when you download the Typescript source of the app and compile it Javascript. It takes more time to install. It contains all recent changes, but all changes are super tested.
You should only use this way, if you know what you are doing and you would like to have all the latest features and you cant wait until the next release :)

The messages you get is fine. Those are warnings. node downloads the required packeges and installs them.
First it tries to download the binaries, when they dont exists, you get a warning and complies them from source.
On a RP3 it takes a long time (even 10-20 mins is ok)

The app also tries to download ffmpeg with node, but thats not supported on a RP3. You will get a warning. You have to install sudo apt-get install ffmpeg manually.

@SummerWine
Copy link
Author

SummerWine commented Jan 27, 2019

Still having problems.

pi@raspberrypi:~/pigallery2 $ npm start

pigallery2@1.5.5 start /home/pi/pigallery2
node ./backend/index.js

internal/modules/cjs/loader.js:583
throw err;
^

Error: Cannot find module '/home/pi/pigallery2/backend/index.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pigallery2@1.5.5 start: node ./backend/index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pigallery2@1.5.5 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2019-01-27T02_17_43_465Z-debug.log


sudo npm start -> no problems


First it worked, then:
Error during initializing SQL falling back temporally to memory DB
"DriverPackageNotInstalledError: SQLite package has not been found installed. Try to install it: npm install sqlite3 --save"

Not possible to repair with: npm install sqlite3 --save


Error:

Meta file support error, switching off..
"Error: *.gpx meta files are not supported without MAP"

@bpatrik
Copy link
Owner

bpatrik commented Jan 27, 2019

Hi,

It looks to me that you have issues with file permissions.
Most likely node (or the user that you use to run node) does not have read (maybe execution is also needed) permission on the <pigalley2 folder>/*.* files.
Furthermore node should be able to write <pigalley2 folder>/config.json and <pigalley2 folder>/sqlite.db files.
You might have the same issue within the installed node modules.


the SQL error might also be because of the permissions, if not then the installation process might have had been terminated in the middle. You can remove the rm -r <pigallery2 path>/node_modules/sqlite3 folder and retry npm install sqlite3.


Your last error means that MAP is switched off in the settings. Once you make the app run, you can switch that back.


In general:

If you have the correct node installed and execute the npm install with the user that you will use to run the app, the app should run.

After that you might still miss something (like ffmpeg for video support), but the app should tell you how to fix that or how to switch off that part of the app if you don't need that module (like video playback)


Also I happen to notice that you are trying to install v1.5.5, there is also v1.5.6 that contains some improvements, see them here: https://github.com/bpatrik/pigallery2/releases

@SummerWine
Copy link
Author

Now i was able to install without errors.

Before "npm install" i used "chmod -R 777 pigallery2". (i know, quick and dirty)

To start the service i use "sudo npm start".

Without "sudo" it won't start and i get the following error:

1/28/2019, 9:45:40 PM[SILLY] Creating thread pool with 1 workers
1/28/2019, 9:45:41 PM[DEBUG] SQL DB inited
1/28/2019, 9:45:41 PM[ERROR] [server] 0.0.0.0:80 requires elevated privileges
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pigallery2@1.5.6 start: node ./backend/index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pigallery2@1.5.6 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2019-01-28T21_45_41_208Z-debug.log

BIG THANKS for your excelent support!!!!

@bpatrik
Copy link
Owner

bpatrik commented Jan 28, 2019

Hi,

Its not super straightforward to open 80 ass non root, you can read about that here:
https://serverfault.com/questions/112795/how-to-run-a-server-on-port-80-as-a-normal-user-on-linux

What I'm doing is, i have nginx (its the recommended way to run a node app):

apt-get install nginx

then edit /etc/nginx/sites-available/default to make a forward, it should look something like this:

server {
        listen 80 default_server;
        listen [::]:80 default_server;


        server_name _;

        location / {
				proxy_pass http://localhost:3000;
				proxy_http_version 1.1;
				proxy_set_header Upgrade $http_upgrade;
				proxy_set_header Connection 'upgrade';
				proxy_set_header Host $host;
				proxy_cache_bypass $http_upgrade;
        }
 
}

Read more here: https://eladnava.com/binding-nodejs-port-80-using-nginx/
then you run pigallery on port 3000.

For running pigallery as a service i recommend to create a system service:
details here: https://stackoverflow.com/questions/4018154/how-do-i-run-a-node-js-app-as-a-background-service and here: https://www.axllent.org/docs/view/nodejs-service-with-systemd/
in short, create a file at pigallery2.service at /etc/systemd/system/pigallery2.service
It should contain this:

[Unit]
Description=Pigallery2
After=network.target

[Service]
WorkingDirectory=/var/www/pigallery2
ExecStart=/usr/bin/node backend/index.js --expose-gc
Restart=on-failure
User=www-data
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target

(maybe the After should also contain nginx, I need to test).
note: the script assumes that pigallery is at /var/www/pigallery2 and node is at /usr/bin/node and also the app will run as www-data user. Make sure that it has the rights to read / execute the right files.

Then you start pigallery2 with:

systemctl enable pigallery2.service
systemctl start pigallery2.service

If you want to have https, use certbot.
Installing instructions for RP3:
https://www.techcoil.com/blog/installing-certbot-on-raspbian-stretch-lite-for-obtaining-lets-encrypts-browser-trusted-certificates/

after you installed certbot, you just call:
sudo certbot --nginx and woala: you have https :) (it also updates your nginx settings)

@bpatrik
Copy link
Owner

bpatrik commented Feb 25, 2019

I'm closing it due to inactivity

@xhabih
Copy link

xhabih commented Jun 12, 2021

For running pigallery as a service i recommend to create a system service:
details here: https://stackoverflow.com/questions/4018154/how-do-i-run-a-node-js-app-as-a-background-service and here: https://www.axllent.org/docs/view/nodejs-service-with-systemd/
in short, create a file at pigallery2.service at /etc/systemd/system/pigallery2.service
[...]

I was using this method with older version of pigallery2

I have updated to actual version and I get this error at daemon.log:

Jun 12 18:29:15 raspberrypi systemd[1]: Started Pigallery2.
Jun 12 18:29:20 raspberrypi node[6108]: 2021-6-12 18:29:20[#033[32mINFO_#033[0m][server] running diagnostics...
Jun 12 18:29:20 raspberrypi node[6108]: Something went wrong installing the "sharp" module
Jun 12 18:29:20 raspberrypi node[6108]: Module did not self-register: '/var/www/pigallery2/node_modules/sharp/build/Release/sharp.node'.
Jun 12 18:29:20 raspberrypi node[6108]: - Remove the "node_modules/sharp" directory, run "npm install" and look for errors
Jun 12 18:29:20 raspberrypi node[6108]: - Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/
Jun 12 18:29:20 raspberrypi node[6108]: - Search for this error at https://github.com/lovell/sharp/issues
Jun 12 18:29:20 raspberrypi systemd[1]: pigallery2.service: Main process exited, code=exited, status=1/FAILURE
Jun 12 18:29:20 raspberrypi systemd[1]: pigallery2.service: Unit entered failed state.
Jun 12 18:29:20 raspberrypi systemd[1]: pigallery2.service: Failed with result 'exit-code'.
Jun 12 18:29:21 raspberrypi systemd[1]: pigallery2.service: Service hold-off time over, scheduling restart.
Jun 12 18:29:21 raspberrypi systemd[1]: Stopped Pigallery2.

I tried to remove the "node_modules/sharp" directory, run "npm install" but problem persist

@bpatrik
Copy link
Owner

bpatrik commented Jun 17, 2021

I'm not sure about this issue. Also installing directly from source is "at your own risk", try using it with docker where everything is preinstalled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants