Giter Club home page Giter Club logo

Comments (8)

BenMcH avatar BenMcH commented on May 24, 2024 1

This will be a chore to implement. If someone wanted to take this on, you could look at utilizing https://github.com/sevlyar/go-daemon

from mole.

davrodpin avatar davrodpin commented on May 24, 2024 1

We're getting there... so, every detached mole instance will have an identifier associated with it and the identifier will be generated either from the alias name or random combination of characters.

Mole would store information about the detached instances under $HOME/.mole/instances.
Each detached instances would have its own directory under $HOME/.mole/instances named after its identifier and the specific instance directory would have a file named mole.pid to store the process identifier, pid, making easier to save/retrieve it.

Examples:

$ mole -start example1 -detach
$ tree $HOME/.mole
$ tree ~/.mole
$HOME/.mole
└── instances
    └── example1
        └── pid
$ mole -stop example1 
$ tree $HOME/.mole
tree ~/.mole
$HOME/.mole
└── instances
$ mole -detach -remote :3306 -server my-server
mole is running under the alias 10df414a.
Execute "mole -stop 10df414a" if you like to stop it at any time
$ tree $HOME/.mole
$ tree ~/.mole
$HOME/.mole
└── instances
    └── 10df414a
        └── pid
$ mole -stop 10df414a
$ tree $HOME/.mole
tree ~/.mole
$HOME/.mole
└── instances

I wouldn't care about handling output redirection right now. The user can always use >, >>, etc. to achieve that.

from mole.

davrodpin avatar davrodpin commented on May 24, 2024

Another good resource about support for daemonize in Go: golang/go#227

from mole.

tidjungs avatar tidjungs commented on May 24, 2024

Can i take this ?
Do i have to implement flag to stop daemon process ?

from mole.

davrodpin avatar davrodpin commented on May 24, 2024

Can i take this ?
Do i have to implement flag to stop daemon process ?

Sure! Thanks for considering contributing to the project, @tidjungs.

Having a command (-stop?) to stop a detached mole instance seems to be a good idea.

Let's assume we will have a flag name -detach to indicate the app should run in background mode and another one, -stop, to stop the app that is already running in background mole.
The latter flag would required an application identifier to be able to stop it, which would be relatively easy to identify if the user had started the app with -start, but I am unsure how to approach the other cases where there is no clear identifier.

One could propose that pid could be provided, but if the app required the user to fetch the pid from the list of processes, then the user could just use kill or something like that.

$ mole -start example1 -detach
INFO[0000] listening on local address                    local_address="127.0.0.1:52218"
$ mole -stop example1

$ mole -detach -remote :3306 -server my-server
INFO[0000] listening on local address local_address="127.0.0.1:52219"
$ mole -stop ???

from mole.

tidjungs avatar tidjungs commented on May 24, 2024

what about

$mole -detach -remote :3306 -server my-server
daemon is running on <alias_name> (maybe name generate with random hex)
stop daemon: $mole -stop <alias_name>

and Alias case

$mole -start example1 -detach
$mole -stop example1

What do you think ?

And I have no idea how to manage structure of pid, log file
what you think about -log=/path/to/log and default is "./"
inside have
pid_alias_name
log_alias_name

from mole.

tidjungs avatar tidjungs commented on May 24, 2024

ok I got it

from mole.

davrodpin avatar davrodpin commented on May 24, 2024

PR #35

from mole.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.