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

Run in detached mode 🔗 #169

Open
jessicafarias opened this issue Jul 19, 2021 · 4 comments
Open

Run in detached mode 🔗 #169

jessicafarias opened this issue Jul 19, 2021 · 4 comments

Comments

@jessicafarias
Copy link

jessicafarias commented Jul 19, 2021

In order to avoid to keep the terminal open and to have multiple paths listening.
I was wondering if you can implement a -d option to keep run and listening witouth having a terminal open (in detached mode or in the background from terminal).
And also a way to check all running process in smee such as docker does with -d and ps.
where: d=detach, ps=process status, rm [prcess_id] = remove/stop process

user@user:~$ smee -d
Forwarding https://smee.io/1PUc3ipJCAKIMTaR to http://127.0.0.1:3000/
Connected https://smee.io/1PUc3ipJCAKIMTaR
Detached

user@user:~$ smee ps
ID           URL                                     PATH      PORT
IDNAME       https://smee.io/1PUc3ipJCAKIMTaR         /        3000

OR:

user@user:~$ smee -d -u https://smee.io/new -P /custom_path/ -p 8080
Forwarding https://smee.io/new to http://127.0.0.1:8080/custom_path
Connected https://smee.io/new
Detached

user@user:~$ smee ps
ID             URL                                 PATH                PORT
NEWIDNAME      https://smee.io/new                 /custom_path        8080
IDNAME         https://smee.io/1PUc3ipJCAKIMTaR    /custom_path        8080

user@user:~$ smee rm NEWIDNAME
Stoping https://smee.io/new
Removed

I tried to use daemon on unix system to run it on background and I found it works for just one smee call. It doesn't work for more than 1 smee call because the smee stay alive when it displays "Connected".

@gr2m
Copy link
Contributor

gr2m commented Jul 19, 2021

It doesn't work for more than 1 smee call because the smee stay alive when it displays "Connected".

I don't quite understand this sentence. Does the daemon crash after receiving the first event?

@jessicafarias
Copy link
Author

jessicafarias commented Jul 19, 2021

I tried to create a new file that contains all smee calls that I need.
After following this tutorial and using this script:

#!/bin/bash
smee -u https://smee.io/custom_url/ -P /generic-webhook-trigger/invoke?token=one -p 8080
smee -u https://smee.io/custom_url/ -P /generic-webhook-trigger/invoke?token=two -p 8080
....
smee -u https://smee.io/tcustom_url/ -P /generic-webhook-trigger/invoke?token=eleven -p 8080

I notice it upload just the first line and ignores the others:

smee -u https://smee.io/custom_url/ -P /generic-webhook-trigger/invoke?token=one -p 8080

I also try to use \ command after each line and doesn't work.

I guessing this is because the first line keeps listening when it returns "Connected". It's my guessing because I notice a same behavior with & command in CLI.

user@user:~$ smee &
Forwarding https://smee.io/99hqrIEtrRkb0B8y to http://127.0.0.1:3000/
hConnected https://smee.io/99hqrIEtrRkb0B8y
------Ctrl+C----- to close smee on terminal and keep running on the background

I need to use Ctrl+C to manually exit to run in background otherwise it stay listening in the console.

@kadler
Copy link

kadler commented Jul 19, 2021

Sounds like you have multiple smee listeners. You could use a tool like nohup to run each in the background in the same shell script (using redirects to save output to different files). Of course, this approach becomes more complicated because now you have to do the child handling in the shell script and if one dies it's not as easy to deal with.

Alternatively, it would be easier to put each listner in to a separate systemd unit files (using the tutorial you linked) and tie them all together using systemd, eg. a systemd target.

@wolfy1339
Copy link
Contributor

Smee is not really intended to be run in the background. It is meant to be used for active development.

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

4 participants