Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.

changed asp_state to listen for (unix) signals #70

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/asp_state/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MCSFLAGS= -debug+ -debug:full -nologo
MCSFLAGS= -debug+ -debug:full -nologo -r:Mono.Posix.dll

if NET_4_0
scripts4 = asp-state4.exe
Expand Down
18 changes: 16 additions & 2 deletions tools/asp_state/asp_state.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using System.IO;
using System.Reflection;
using System.Runtime.Remoting;
using Mono.Unix;
using Mono.Unix.Native;

namespace Mono.ASPNET.Tools {

Expand Down Expand Up @@ -64,10 +66,22 @@ private static void ShowVerboseConfigurationInfo(string filename)
public static void Main (string [] args)
{
if (args.Length == 0) {
UnixSignal [] signals = new UnixSignal[] {
new UnixSignal(Signum.SIGINT),
new UnixSignal(Signum.SIGTERM),
};
RemotingConfiguration.Configure (ConfigurationFileName, false);
ShowVerboseConfigurationInfo(ConfigurationFileName);
Console.Write("Press <Enter> to stop...");
Console.ReadLine ();

// Wait for a unix signal to exit
for (bool exit = false; !exit; )
{
int id = UnixSignal.WaitAny(signals);
if (id >= 0 && id < signals.Length)
{
if (signals[id].IsSet) exit = true;
}
}
} else {
ShowUsage();
}
Expand Down