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

Try to run script-server on ubuntu-server #781

Open
adripalu opened this issue Jan 29, 2025 · 12 comments
Open

Try to run script-server on ubuntu-server #781

adripalu opened this issue Jan 29, 2025 · 12 comments

Comments

@adripalu
Copy link

Hi @bugy congrats for this amazing tool.
I'm trying to use script-server for my job but i'm stuck in a loop. My goal is to run the scripts present on a ubuntu-server machine from the script-server broswer interface.
To do that I installed script-server on the remote machine and ran the launcher in a docker container, as mentioned here. Thanks to that I'm able to open the localhost:5000 page and run the scripts.

Image

Now i have three problems:

  1. When i close the ssh terminal, the web page crash

Image

  1. If I try to run the launcher.py as service, exactly as mentioned here, the service does not start (or if start, when i close the terminal it crash), whether I specify ExecStart with python command (ExecStart=sudo /home/server/.python_venv/script-server/bin/python /home/server/projects/script-server/launcher.py) or via docker
    (ExecStart=/usr/bin/docker run -d -p 5000:5000 -v /host/path/to/conf.json:/app/conf/conf.json -v /host/path/to/runners/:/app/conf/runners -v /host/path/to/scripts/:/app/custom_projects/ bugy/script-server:1.18.0).

  2. The only web page that i can succesfully use is the localhost page and not the ip server page. Infact, even if i specify the server ip in the "address" field of conf.json, the page doesn't open.
    For example this is my conf.json:

Image

I know these are a lot of questions, but your help would be greatly appreciated.
Thanks

@MNeill73
Copy link

MNeill73 commented Jan 29, 2025 via email

@MNeill73
Copy link

MNeill73 commented Jan 29, 2025 via email

@bugy
Copy link
Owner

bugy commented Jan 29, 2025

Hi @adripalu

Regarding 1 and 2: how do you run script server? Do you just ssh and then run launcher from a command line?
Could it be related? https://www.reddit.com/r/docker/comments/r53hsh/docker_goes_to_sleep_as_soon_as_i_quit_the_ssh/

Regarding 3: did you try to run any other remote services? When you are in your ssh session, can you try wget your_server_ip:5000/index.html (you can use curl instead of wget)
Also don't use address option. It's too complicated under docker. Default setting is the most permissive one

@adripalu
Copy link
Author

Thanks for the answers

@MNeill73
Yes, /app/conf/* and /app/custom_projects are the path mounted in the container and /host/path/to/* are the path in the ssh filesystem.
Are you saying that I should mount the paths of my local filesystem on docker container and not the paths of the ssh filesystem?

@bugy
1-2) Yes, i just access to the server with ssh and then run the launcher via cli (docker or python env).
Yes, my issue is exactly the same of the link. I tried to run the launcher in the tmux session as suggested there, but still the same problems: when i close ssh the web page crash.
3) I tried to wget/curl http://ip_erver/index.html and it doesn't work, but it works with http://0.0.0.0:5000 (default conf.json, no address specified).

I also tried to run the launcher with nohup with the following commands:
nohup /home/server/.python_venv/script-server/bin/python /home/server/projects/script-server/launcher.py > nohup.out & or nohup docker run -d -p 5000:5000 -v /host/path/to/conf.json:/app/conf/conf.json -v /host/path/to/runners/:/app/conf/runners -v /host/path/to/scripts/:/app/custom_projects/ bugy/script-server:1.18.0 > nohup.out & but the web page (if start) still crash after exit from ssh.

I'd like to have SS running as service (with docker o python script) to have it always up and running. Infact, the ultimate goal is to allow my colleagues to run my scripts on SS from their PCs when I'm not present in the lab

@bugy
Copy link
Owner

bugy commented Jan 30, 2025

  1. I tried to wget/curl http://ip_erver/index.html and it doesn't work, but it works with http://0.0.0.0:5000/ (default conf.json, no address specified).

Did you specify the port? http://ip_erver/index.html it's not here

Yes, my issue is exactly the same of the link. I tried to run the launcher in the tmux session as suggested there

I think the correct way to go is to run script server as a service. Which error do you get, when you try to run it as a service?

@adripalu
Copy link
Author

@bugy
Yes i specified the default port (5000), i just forget to mention it in the last message, I'm sorry.
Ok I'm going to run it again as a service. Do you suggest to run the launcher with the docker or with the python env ?
Should I use "address" with the server ip or it's better to leave the default conf.json?

@bugy
Copy link
Owner

bugy commented Jan 30, 2025

Run it as a python for simplicity
And use default conf

@adripalu
Copy link
Author

This is my conf.json file

{
    "title" : "Pipelines runner"
}

this is the script-server.service file:

[Unit]
Description=Script Server
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/home/server/.python_venv/script-server/bin/python /home/server/projects/script-server/launcher.py

[Install]
WantedBy=multi-user.target

actived with:

systemctl enable script-server.service
systemctl start script-server.service

As you can see below, the service succesfully started and the web page works.

● script-server.service - Script Server
     Loaded: loaded (/usr/lib/systemd/system/script-server.service; enabled; preset: enabled)
     Active: active (running) since Thu 2025-01-30 14:18:51 UTC; 6min ago
   Main PID: 1703920 (python)
      Tasks: 4 (limit: 230383)
     Memory: 20.0M (peak: 20.4M)
        CPU: 263ms
     CGroup: /system.slice/script-server.service
             └─1703920 /home/server/.python_venv/script-server/bin/python /home/server/projects/script-server/launcher.py

Jan 30 14:18:51 ubuntu systemd[1]: Started script-server.service - Script Server.
Jan 30 14:18:51 ubuntu python[1703920]: 2025-01-30 14:18:51,556 [root.INFO] Starting Script Server, v1.18.0
Jan 30 14:18:51 ubuntu python[1703920]: 2025-01-30 14:18:51,561 [asyncio.DEBUG] Using selector: EpollSelector
Jan 30 14:19:25 ubuntu python[1703920]: Server is running on: http://0.0.0.0:5000
Jan 30 14:19:25 ubuntu python[1703920]: 2025-01-30 14:19:25,322 [tornado.access.INFO] 302 GET / (127.0.0.1) 0.55ms
Jan 30 14:19:25 ubuntu python[1703920]: 2025-01-30 14:19:25,341 [tornado.general.ERROR] Could not open static file '/home/server/projects/script-server/conf/theme/theme.css'
Jan 30 14:19:25 ubuntu python[1703920]: 2025-01-30 14:19:25,341 [tornado.access.INFO] 200 GET /theme/theme.css (127.0.0.1) 0.70ms
Jan 30 14:19:25 ubuntu python[1703920]: 2025-01-30 14:19:25,417 [tornado.access.INFO] 304 GET /auth/info (127.0.0.1) 0.75ms
Jan 30 14:19:25 ubuntu python[1703920]: 2025-01-30 14:19:25,420 [tornado.access.INFO] 304 GET /conf (127.0.0.1) 0.41ms
Jan 30 14:19:25 ubuntu python[1703920]: 2025-01-30 14:19:25,425 [tornado.access.INFO] 304 GET /scripts (127.0.0.1) 1.37ms
Jan 30 14:19:25 ubuntu python[1703920]: 2025-01-30 14:19:25,429 [tornado.access.INFO] 304 GET /executions/active (127.0.0.1) 0.80ms
Jan 30 14:19:28 ubuntu python[1703920]: 2025-01-30 14:19:28,315 [tornado.access.INFO] 200 GET /theme/theme.css (127.0.0.1) 1.28ms
Jan 30 14:19:28 ubuntu python[1703920]: 2025-01-30 14:19:28,358 [tornado.access.INFO] 304 GET /auth/info (127.0.0.1) 1.29ms
Jan 30 14:19:28 ubuntu python[1703920]: 2025-01-30 14:19:28,359 [tornado.access.INFO] 304 GET /executions/active (127.0.0.1) 1.08ms
Jan 30 14:19:28 ubuntu python[1703920]: 2025-01-30 14:19:28,362 [tornado.access.INFO] 304 GET /scripts (127.0.0.1) 2.04ms
Jan 30 14:19:28 ubuntu python[1703920]: 2025-01-30 14:19:28,363 [tornado.access.INFO] 304 GET /conf (127.0.0.1) 1.07ms

Again, when i close the ssh the web crash as the photo posted above.

@bugy
Copy link
Owner

bugy commented Jan 30, 2025

Just to double check: are you sure, that your server keeps running after you close ssh?
What kind of the server do you have?

@adripalu
Copy link
Author

Yes I'm 100% sure that the server keeps running after I close ssh.
The server is Ubuntu 24.04.1 LTS.
Searching on web here, here2, here3 I'm thinking that maybe it's a normal systemd/ssh behaviour that I must change.

Anyway, the problem to the server ip still remain, infact i can connect only to localhost.

@bugy
Copy link
Owner

bugy commented Jan 30, 2025

Anyway, the problem to the server ip still remain, infact i can connect only to localhost.

to double-check, is ifconfig showing the same IP, as you are trying to access?
May be there is some external gateway, which assigns the IP and server is not aware of it. The first step we must achieve is to make wget work locally (in SSH session)

@adripalu
Copy link
Author

Yes the IP is the same as the one I am trying to access.
I tried nohup, tmux , loginctl enable-linger commands, switch the service from /lib/systemd/system/ to /etc/systemd/system/...but nothing. In addition, it appears that the service is tied to the vscode window from which I have ssh access to the server.
I think is a service/server related issue.
Still open to any suggestions.

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

3 participants