V
V
Victor P.2018-09-28 15:10:17
linux
Victor P., 2018-09-28 15:10:17

How to autostart node.js server in Ubuntu Core?

Good afternoon!
I need to raise a node.js server on ubuntu core on raspberry pi.
I went to the ubunta website, they offered me several images and it was written that ubuntu core is best suited, it is lightweight and immediately sets up Wi-Fi (before that, I didn’t manage to set up Wi-Fi in the console version at all). I downloaded the image, wrote it to a flash drive, inserted it into a raspberry, connected via putty. Well, it wasn't all smooth sailing, of course, but it all worked out in the end.
Then I started installing the programs I needed and found that apt-get was not working. A quick google gave me this:

sudo snap install classic —devmode —edge
sudo classic

After that, everything started working, I installed nodejs, npm, git, downloaded some kind of helloworld created on my home computer, launched it, saw the welcome page through the browser from the phone, everything works. I installed pm2, launched the server through it, added it to autoload, everything turned out and went to bed.
The next day I launched my raspberry, opened the browser on my computer, the site does not plow. Connected to raspberry, commands do not work. Pressed again
sudo classic
Then hands started the server.
That is, autoload does not work and it's sad.
As far as I understand, I either need to somehow run pm2 in core mode, or add some kind of thing so that when the system boots, the system itself enters this classic mode, after which it should start its autoloads.
When installing the server, I used this tutorial (before the section about nginx) Tyts

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Victor P., 2020-09-21
@Jeer

Who cares, I made a similar setting on raspbian, and it remained on it, apparently, something was wrong with the ubuntu distribution

S
Sergey Ganin, 2018-09-28
@dohera

It seems to me that pm2 should have a command to add to autorun. Or, you can add your own. https://help.ubuntu.ru/wiki/%D1%81%D0%BE%D0%B7%D0%...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question