Git Product home page Git Product logo

spm's Introduction

spm - Simple Process Manager

spm is somewhere between systemd and foreman.

It runs as a daemon. You can start spm daemon by running spm command with no arguments. Once you've done that you are ready to start and manage your jobs(processes) with spm commands. spm reads its jobs from an extended Procfile syntax. You are eligible to start or stop jobs, see running jobs and their logs. Your processes executed as shell commands so you're allowed to use shell syntax in your Procfile.

Our extended version of Procfile syntax supports comments with # sign and multilines with \.

Why spm ?

All other foreman like process managers don't have a proper stop feature to end running jobs which spm has. spm works in a client/server convention, spm daemon listens for job commands(listed at spm -h) from it's clients through unix sockets. You are also able to use multiple Procfiles and start/stop multiple jobs in a Procfile which gives a huge flexiblity when you need to work with bunch of long running processes. Jobs are recognized by their names, make sure that your jobs has unique names otherwise spm will not start an already running job with same name that you started before.

Installation and Usage

$ go get github.com/bytegust/spm/cmd/spm
$ spm -h

Simple Process Manager.

Usage: spm [OPTIONS] COMMAND [arg...]
       spm [ --help ]

Options:

  -f, --file=~/.Procfile    Location of Procfile
  -h, --help                Print usage

Commands:

    start           Start all jobs defined in Procfile
    start <jobs>    Starts jobs if present in Procfile
    stop            Stop all current jobs
    stop <jobs>     Stop jobs if currently running
    list            Lists all running jobs
    logs <job>      Prints last 200 lines of job's logfile 

Documentation can be found at https://github.com/bytegust/spm

Example

Following Procfile has two jobs (tabs for legibility):

# Serve spm's github repository on local machine
repo:   rm -rf spm && \
        git clone https://github.com/bytegust/spm.git && \
        http-server ./spm -p 8080

# Download and serve a webpage on local machine
apod: \

        # Create directory that will be served
        rm -rf astropix && \
        mkdir astropix && \
        cd astropix && \

        # Downloads the content of https://apod.nasa.gov/apod/astropix.html
        wget -A.jpg -e robots=off -k \ 
        --user-agent="Mozilla/5.0 (compatible; Konqueror/3.0.0/10; Linux)" \
        --no-check-certificate https://apod.nasa.gov/apod/astropix.html && \

        # Rename file as index
        mv $(ls *.html | head -1) index.html && \

        # Serve webpage
        http-server -p 8081

Suppose that we have the Procfile above inside a folder named test. After starting the daemon by spm command we will be able to run jobs, inside our Procfile, from the clients, namely, other terminal windows or tabs.

  1. Run spm command to start daemon:

    $ spm
    2016/11/07 22:20:22 spm.go:209: deamon started
    

  2. Run spm start (or a specific job e.g. spm start apod) command from different terminal tab. Since our Procfile reside in the folder named test, we have to define its path using -f flag:

    $ spm -f test start
    2016/11/07 22:20:23 spm.go:122: done
    

  3. Log files are being saved under /tmp folder with a job specific name, so that it's possible to see logs by spm logs <jobname> command:

    $ spm logs apod
    
  4. List all running jobs using spm list command:

    $ spm list
    
  5. Stop running jobs using spm stop command (or a specific job e.g. spm stop apod):

    $ spm stop
    

spm's People

Contributors

ilgooz avatar serhansevim avatar ufukomer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

spm's Issues

Implement kill command

I think kill command with optional -s parameter (to specify signal type) will be helpful for the following case:

Example Procfile:

confd: exec confd -backend etcd -watch -config-file myconfig.toml
nginx: exec nginx -g 'daemon off;'

Example myconfig.toml:

[template]
src = "/etc/nginx/nginx.conf.tmpl"
dest = "/etc/nginx/nginx.conf"
reload_cmd = "spm kill -s HUP nginx"

Thanks for this command we can send some signals to running jobs, without known its current pid.

Is it possible that this feature will be implemented?

improve readme

add more explanation/screen shots to readme about spm.

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.