pm2tgo

command module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2023 License: MIT Imports: 13 Imported by: 0

README

PM2TGO

PM2TGO is a lightweight process manager written in Golang for Golang applications. It helps you keep your applications alive forever, reload and start them from the source code.

Install pm2tgo

$ go install github.com/hoangnguyen1247/pm2tgo@latest
$ mv $GOPATH/bin/pm2tgo /usr/local/bin

Or

git clone https://github.com/hoangnguyen1247/pm2tgo.git
cd path/to/hoangnguyen1247/pm2tgo
go build -v pm2tgo.go
mv pm2tgo /usr/local/bin

Starting a new application

If it's the first time you are starting a new golang application, you need to tell pmgo to first build its binary. Then you need to first run:

$ pm2tgo start path/to/source-directory app-name

This will automatically compile, start and daemonize your application. If you need to later on, stop, restart or delete your app from PMGO, you can just run normal commands using the app-name you specified. Example:

$ pm2tgo stop app-name
$ pm2tgo restart app-name
$ pm2tgo delete app-name

Main features

Commands overview
$ pm2tgo kill                                                  # kill pm2tgo daemon process

$ pm2tgo start source app-name                                 # Compile, start, daemonize and auto  restart application.
$ pm2tgo restart app-name                                      # Restart a previously saved process
$ pm2tgo stop app-name                                         # Stop application.
$ pm2tgo delete app-name                                       # Delete application forever.

$ pm2tgo save                                                  # Save current process list

$ pm2tgo list                                                  # Display status for each app.
$ pm2tgo info app-name                                         # describe importance parameters of a process name
Start your GO-application with parameters
// pm2tgo will build your source code folder under $GOPATH/src by default
// Here my tmp folder was: $GOPATH/src/tmp
pm2tgo start tmp/ test --args "arg1 arg2 arg3"

# In your application
fmt.Println(os.Args[1:])
# Output: [arg1, arg2, arg3]
Start application from user input compiled binary
# true means use user input compiled binary path
pm2tgo start /Users/strucoder/personalPro/goplace/main awesome_name true --args="arg1 arg2 arg3"
Demo

demo

I Love This. How do I Help?
  • Simply star this repository :-)
  • Help us spread the world on Facebook and Twitter
  • Contribute Code!
  • I'll be very grateful if you'd like to donate to encourage me to continue maintaining pmgo.
Contributors
Donate
Paypal Alipay
paypal not yet
By The Way

In China Mainland, maybe you can't download some packages in golang.org, thus just click here to set GOPROXY

LICENSE

MIT

Documentation

Overview

PMGO is a lightweight process manager written in Golang for Golang applications. It helps you keep all of your applications alive forever, if you want to. You can also reload, start, stop, delete and query status on the fly.

PMGO also provide a way to start a process by compiling a Golang project source code.

The main PMGO module is the Master module, it's the glue that keep everything running as it should be.

If you need to use the remote version of PMGO, take a look at RemoteMaster on Master package.

To use the remote version of PMGO, use:

- remoteServer := master.StartRemoteMasterServer(dsn, configFile)

It will start a remote master and return the instance.

To make remote requests, use the Remote Client by instantiating using:

- remoteClient, err := master.StartRemoteClient(dsn, timeout)

It will start the remote client and return the instance so you can use to initiate requests, such as:

- remoteClient.StartGoBin(sourcePath, name, keepAlive, args)

Directories

Path Synopsis
lib
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL