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

Automatic start on Linux with reboot #47

Open
jd710313 opened this issue Sep 21, 2021 · 3 comments
Open

Automatic start on Linux with reboot #47

jd710313 opened this issue Sep 21, 2021 · 3 comments
Labels
needs more info Further information is requested

Comments

@jd710313
Copy link

I got the app server to work on Linux and it is a really elegant solution with everything packaged in one installation and for the full stack!
It does however require manual user startup through the:
anvil-app-server --app
command and I would like to get it to start up with the Linux OS. I tried using a systemd service:
[Unit]
Description=Anvil Material_Design_1
After=multi-user.target
[Service]
Type=idle
ExecStart=/home/anvil/env/bin/python /home/anvil/env/bin/anvil-app-server --app Material_Design_1 > /home/anvil/Material_Design_1.log 2>&1
WorkingDirectory=/home/anvil
User=anvil
[Install]
WantedBy=multi-user.target

but it does not start successfully as a service and I get the following error:
Material_Design_1.service - Anvil Material_Design_1
Loaded: loaded (/etc/systemd/system/Material_Design_1.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2021-09-21 17:13:29 SAST; 22min ago
Sep 21 17:13:29 raspberrypi python[12481]: --microsoft-app-id APP_ID App ID to use for Microsoft authentSep 21 17:13:29 raspberrypi systemd[1]: Material_Design_1.service: Main process exited, code=exited, status=1/FAILURE
Sep 21 17:13:29 raspberrypi systemd[1]: Material_Design_1.service: Failed with result 'exit-code'.

The manual startup from the terminal does work.

Is there perhaps a solution or guide on how to get the app server to start automatically with startup of the OS?

Thanks

@JackN-code
Copy link

JackN-code commented Nov 11, 2021

You must run this first
anvil-app-server --app my_app --origin http://my_ip.com

then

sudo nano /etc/systemd/system/anvil_Jack.service

[Unit]
Description=ROT13 demo service
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=[you_ubuntu_non_root_user]
ExecStart=anvil-app-server --app my_app --origin http://my_ip.com
[Install]
WantedBy=multi-user.target

sudo chmod 644 /etc/systemd/system/anvil_Jack.service
sudo systemctl enable anvil_Jack.service

sudo systemctl start anvil_Jack.service

Done

sudo systemctl stop anvil_Jack.service
sudo systemctl status anvil_Jack.service

@meredydd
Copy link
Collaborator

Hi @jd710313,

Are you still having this problem? My guess is that you've got something squiffly in how you're specifying your app's config, so the App Server is refusing to start and that tiny fragment of log you're seeing is the last line of the usage message (summarising the available command-line arguments). If you try printing the whole log (with journalctl), you might see the actual error message from the App Server.

@meredydd meredydd added the needs more info Further information is requested label May 30, 2022
@jd710313
Copy link
Author

jd710313 commented Jun 2, 2022

Hi @jd710313,

Are you still having this problem? My guess is that you've got something squiffly in how you're specifying your app's config, so the App Server is refusing to start and that tiny fragment of log you're seeing is the last line of the usage message (summarising the available command-line arguments). If you try printing the whole log (with journalctl), you might see the actual error message from the App Server.

Hi Meredyd,

Thanks I eventually got it working. I can't remember the exact solution, but looking at my notes I believe there was an unprivileged port issue for the service that I had to enable with:
sudo echo 'net.ipv4.ip_unprivileged_port_start=0' > /etc/sysctl.d/50-unprivileged-ports.conf
and then also enabling the service with:
sudo systemctl --force --full edit Material_Design_1.service

It was running on a Raspberry Pi with their OS, so this could have been issues specific to the Pi. Anyway I got it running and it is really impressive to see this full-stack app running on a Pi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants