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

Add a reload command #49

Closed
smimram opened this issue Mar 26, 2013 · 15 comments
Closed

Add a reload command #49

smimram opened this issue Mar 26, 2013 · 15 comments

Comments

@smimram
Copy link
Member

smimram commented Mar 26, 2013

This feature was requested on the ML:

Addition for system, a reload command which shuts down everything, (re)loads the running script and runs again. This makes reloading possible on the liquidsoap level rather than the OS level.

@dbaelde
Copy link
Member

dbaelde commented Mar 26, 2013

If possible, I'd like this to be done from outside liquidsoap (have an
external script ask liquidsoap to shutdown, and reload it) rather than
clutter our main.ml file, unless there is a good reason for it.

@smimram
Copy link
Member Author

smimram commented Mar 26, 2013

Well, it would be nice to have it in Liquidsoap (in the standard library). It could be implemented by invoking suitable external command, and we should have the name of the script in argv.(0). It would be nice if we code it plainly in utils.liq, without requiring an external script.

@dbaelde
Copy link
Member

dbaelde commented Mar 27, 2013

Yes, utils.liq is no problem for me, I was just begging that we don't
change the ML code.

@mkonecny
Copy link
Contributor

mkonecny commented Apr 9, 2013

This would be very nice! 👍

@smimram
Copy link
Member Author

smimram commented Apr 10, 2013

I came up with something like this:

# Restart the currently running script.
def restart() =
  relaunch = "liquidsoap #{argv(0)} #{argv(1)} #{argv(2)} #{argv(3)}"
  # print("relaunch command: #{relaunch}")
  cmd = "{ while `ps -p #{getpid()} > /dev/null`; do sleep 1; done; echo \"Liquidsoap died\"; #{relaunch}; }&"
  system(cmd)
  shutdown()
end

It does not work (yet) but it might be a good starting point of an implementation without deep modifications of Liquidsoap.

@mkonecny
Copy link
Contributor

Interesting, but that would be *nix dependent no? Or are you guys running in cygwin with your Windows port?

@smimram
Copy link
Member Author

smimram commented Apr 12, 2013

This was just a try to implement this purely in Liquidsoap. However I am not really convinced by this way or proceeding. I think I'll try to make a new builtin command, which moreover would be more portable...

@mkonecny
Copy link
Contributor

This would actually be really useful for us, since I am currently running one of Airtime's background processes as root only only because restart requires calling init.d scripts.

BTW a small nit-pick. I first assumed this feature was related to allowing Liquidsoap to continue running while "reloading" its config files. Perhaps this should be called "restart".

@asantoni
Copy link

What is the use case for "shutting down everything"?

Wouldn't a reload command be much more useful if it didn't interrupt playback? How is Liquidsoap supposed to be used for broadcasting if reconfiguration requires dead air?

@dbaelde
Copy link
Member

dbaelde commented Nov 20, 2013

@asantoni Given the richness of liquidsoap scripts it is not generally feasible to reload without interrupting playback. The current issue is to provide a convenient way to do the only thing that we can support in general, ie. shut down everything, read the script again, and restart asap.

In practice, people have a simple fallback for their radio (which can be setup at the icecast level, or using a simple liquidsoap script) that is never restarted, and plays an interlude when the real radio is being restarted.

@ALuserX
Copy link

ALuserX commented Nov 20, 2013

That's a great feature I missed so much. I also hope it will be possible to restart via telnet.

[OFFTOPIC]BTW, @asantoni could you possibly point me to a working example of the fallback you're talking about. That would be really great.[/OFFTOPIC]

@smimram
Copy link
Member Author

smimram commented Nov 26, 2013

I tired to implement something in this direction in #135.

@smimram
Copy link
Member Author

smimram commented Nov 26, 2013

Side note, my test file is

set("log.file",false)
set("log.stdout",true)
set("log.level",5)
set("server.telnet",true)
set("init.catch_exn",false)

n = ref 0

def r(m) =
  n := !n + 1
  if !n > 1 then restart() end
end

s = playlist("~/Music")
s = on_metadata(r,s)
s = audio_to_stereo(s)
s = mksafe(s)
s = fallback([s,input.harbor("/test")])

output.pulseaudio(id="pa",s)

when you pa.skip on the telnet, it restarts! :)

@smimram
Copy link
Member Author

smimram commented Dec 12, 2013

The branch #135 has been merged. It add as restart command to Liquidsoap.

@mylselgan
Copy link

Hi, I want to restart the whole script if the main source failed and mksafe called or static emergency single called could you please give me any example here

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

6 participants