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

Running Reflex via systemd stopped working after v.0.6.2 #4560

Open
givaha opened this issue Dec 19, 2024 · 2 comments
Open

Running Reflex via systemd stopped working after v.0.6.2 #4560

givaha opened this issue Dec 19, 2024 · 2 comments

Comments

@givaha
Copy link

givaha commented Dec 19, 2024

Describe the bug
Running Reflex via systemd service stopped working after v.0.6.2.
I create a .sh-script that the systemd service uses to keep reflex running (see steps to reproduce)
The steps to reproeduce the issue work on version 0.6.2.

To Reproduce
Steps to reproduce the behavior:

# Create virtual environment
python3 -m venv venv
source venv/bin/activate

# Install Reflex (0.6.7, latest version)
pip3 install reflex 

# Create Reflex project (blanco)
reflex init 
0

# Create a bash 'service_startup.sh' script with this content + give execute rights (sudo chmod +x service_startup.sh)
source /home/user/folder/venv/bin/activate
reflex run --loglevel debug --frontend-port 3001 --backend-port 8001

# Create a systemd service (reflex.service in /etc/systemd/system)
[Unit]
Description=Reflex App
After=network.target

[Service]
WorkingDirectory=/home/user/folder
ExecStart=/home/user/folder/service_startup.sh
Restart=always

[Install]
WantedBy=multi-user.target

# Start the service
**sudo** systemctl start reflex.service

This will give error:

dec 19 14:15:49 server service_startup.sh[1773120]:   File "/home/user/folder/venv/bin/reflex", line 8, in <module>
dec 19 14:15:49 server service_startup.sh[1773120]:     sys.exit(cli())
dec 19 14:15:49 server service_startup.sh[1773120]:              ^^^^^
dec 19 14:15:49 server service_startup.sh[1773120]:   File "/home/user/folder/venv/lib/python3.12/site-packages/typer/main.py", line 340, in __call__
dec 19 14:15:49 server service_startup.sh[1773120]:     raise e
dec 19 14:15:49 server service_startup.sh[1773120]:   File "/home/user/folder/venv/lib/python3.12/site-packages/typer/main.py", line 323, in __call__
dec 19 14:15:49 server service_startup.sh[1773120]:     return get_command(self)(*args, **kwargs)
dec 19 14:15:49 server service_startup.sh[1773120]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dec 19 14:15:49 server service_startup.sh[1773120]:   File "/home/user/folder/venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
dec 19 14:15:49 server service_startup.sh[1773120]:     return self.main(*args, **kwargs)
dec 19 14:15:49 server service_startup.sh[1773120]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^
dec 19 14:15:49 server service_startup.sh[1773120]:   File "/home/user/folder/venv/lib/python3.12/site-packages/typer/core.py", line 743, in main
dec 19 14:15:49 server service_startup.sh[1773120]:     return _main(
dec 19 14:15:49 server service_startup.sh[1773120]:            ^^^^^^
dec 19 14:15:49 server service_startup.sh[1773120]:   File "/home/user/folder/venv/lib/python3.12/site-packages/typer/core.py", line 198, in _main
dec 19 14:15:49 server service_startup.sh[1773120]:     rv = self.invoke(ctx)
dec 19 14:15:49 server service_startup.sh[1773120]:          ^^^^^^^^^^^^^^^^
dec 19 14:15:49 server service_startup.sh[1773120]:   File "/home/user/folder/venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
dec 19 14:15:49 server service_startup.sh[1773120]:     return _process_result(sub_ctx.command.invoke(sub_ctx))
dec 19 14:15:49 server service_startup.sh[1773120]:                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dec 19 14:15:49 server service_startup.sh[1773120]:   File "/home/user/folder/venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
dec 19 14:15:49 server service_startup.sh[1773120]:     return ctx.invoke(self.callback, **ctx.params)
dec 19 14:15:49 server service_startup.sh[1773120]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dec 19 14:15:49 server service_startup.sh[1773120]:   File "/home/user/folder/venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
dec 19 14:15:49 server service_startup.sh[1773120]:     return __callback(*args, **kwargs)
dec 19 14:15:49 server service_startup.sh[1773120]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
dec 19 14:15:49 server service_startup.sh[1773120]:   File "/home/user/folder/venv/lib/python3.12/site-packages/typer/main.py", line 698, in wrapper
dec 19 14:15:49 server service_startup.sh[1773120]:     return callback(**use_params)
dec 19 14:15:49 server service_startup.sh[1773120]:            ^^^^^^^^^^^^^^^^^^^^^^
dec 19 14:15:49 server service_startup.sh[1773120]:   File "/home/user/folder/venv/lib/python3.12/site-packages/reflex/reflex.py", line 285, in run
dec 19 14:15:49 server service_startup.sh[1773120]:     _run(env, frontend, backend, frontend_port, backend_port, backend_host, loglevel)
dec 19 14:15:49 server service_startup.sh[1773120]:   File "/home/user/folder/venv/lib/python3.12/site-packages/reflex/reflex.py", line 219, in _run
dec 19 14:15:49 server service_startup.sh[1773120]:     setup_frontend(Path.cwd())
dec 19 14:15:49 server service_startup.sh[1773120]:   File "/home/user/folder/venv/lib/python3.12/site-packages/reflex/utils/build.py", line 235, in setup_frontend
dec 19 14:15:49 server service_startup.sh[1773120]:     prerequisites.get_package_manager(),
dec 19 14:15:49 server service_startup.sh[1773120]:     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dec 19 14:15:49 server service_startup.sh[1773120]:   File "/home/user/folder/venv/lib/python3.12/site-packages/reflex/utils/prerequisites.py", line 249, in get_package_manager
dec 19 14:15:49 server service_startup.sh[1773120]:     raise FileNotFoundError("NPM not found. You may need to run `reflex init`.")
dec 19 14:15:49 server service_startup.sh[1773120]: FileNotFoundError: NPM not found. You may need to run `reflex init`.
dec 19 14:15:49 server service_startup.sh[1773120]: [14:15:49] Reflex app stopped.

Expected behavior
Systemd service running for reflex

Screenshots
If applicable, add screenshots to help explain your problem.

Specifics (please complete the following information):

  • Python Version: 3.12.3
  • Reflex Version: 0.6.7
  • OS: Ubuntu 24.04.1 LTS
  • Browser (Optional): -
Copy link

linear bot commented Dec 19, 2024

@tjzzhang
Copy link

I have the same problem.
Dec 21 23:47:01 iZ2vc07gyshgakdxvl4s2vZ reflex[34951]: _run(env, frontend, backend, frontend_port, backend_port, backend_host, loglevel)
Dec 21 23:47:01 iZ2vc07gyshgakdxvl4s2vZ reflex[34951]: File "/home/workplace/.venv/lib/python3.12/site-packages/reflex/reflex.py", line 219, in _run
Dec 21 23:47:01 iZ2vc07gyshgakdxvl4s2vZ reflex[34951]: setup_frontend(Path.cwd())
Dec 21 23:47:01 iZ2vc07gyshgakdxvl4s2vZ reflex[34951]: File "/home/workplace/.venv/lib/python3.12/site-packages/reflex/utils/build.py", line 235, in s>
Dec 21 23:47:01 iZ2vc07gyshgakdxvl4s2vZ reflex[34951]: prerequisites.get_package_manager(),
Dec 21 23:47:01 iZ2vc07gyshgakdxvl4s2vZ reflex[34951]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dec 21 23:47:01 iZ2vc07gyshgakdxvl4s2vZ reflex[34951]: File "/home/workplace/.venv/lib/python3.12/site-packages/reflex/utils/prerequisites.py", line 2>
Dec 21 23:47:01 iZ2vc07gyshgakdxvl4s2vZ reflex[34951]: raise FileNotFoundError("NPM not found. You may need to run reflex init.")
Dec 21 23:47:01 iZ2vc07gyshgakdxvl4s2vZ reflex[34951]: FileNotFoundError: NPM not found. You may need to run reflex init.
Dec 21 23:47:01 iZ2vc07gyshgakdxvl4s2vZ reflex[34951]: [23:47:01] Reflex app stopped. console.py:161

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

No branches or pull requests

2 participants