Skip to content

Headless employee leave management in Rust built on Slack for small businesses.

Notifications You must be signed in to change notification settings

vaibhavpandeyvpz/leaveme

Repository files navigation

leaveme

Screenshot

Headless employee leave management in Rust built on Slack for small businesses. Record leave requests, require manager approval and leave(s) history etc. provided as Slack slash command(s).

Build status GitHub Release GitHub Downloads (all assets, all releases)

Usage

Grab a binary from the latest release for your platform from this page. In the same folder as binary, create a config.yml file from the sample in the repository using below command:

wget -O config.yml https://raw.githubusercontent.com/vaibhavpandeyvpz/leaveme/main/config.dist.yml

Then go to api.slack.com, create a new app using provided manifest (see slack.dist.yml) and install it on a Slack workspace. Once done, make note of the signing secret as well as bot access token shown in Slack.

Update your Slack credentials in config.yml file and start the app server using below command:

./leaveme --config=config.yml

Since Slack needs to communicate with your app for certain functionality, it's recommended to run this on a server and install an SSL certificate.

Development

Make sure you have Docker installed on your workstation. For the IDE, I highly recommend using RustRover i.e., my goto choice for Rust development.

Download or clone the project using Git and then run following commands in project folder:

# create .env file in project
cp .env.dist .env

# update NGROK_AUTHTOKEN in .env

# create app config file
cp config.dist.yml config.yml

# update values in config.yml

# create ngrok config file
cp ngrok.dist.yml ngrok.yml

# update ngrok domain in ngrok.yml

# create Slack app manifest
cp slack.dist.yml slack.yml

# update ngrok domain in slack.yml

# start all services
docker compose up -d

Deployment

For deployment, using a pre-built binary from Releases section is the easiest way to go.

You could also use Docker for deployment. There's a bundled Dockerfile that builds and exposes the server on port 8000.

To build the Docker container locally, use below command:

docker build -t leaveme .
# or 
docker build -t ghcr.io/vaibhavpandeyvpz/leaveme .

Container once pushed, can be pulled and run directly as below:

docker run -it --rm \
  -p "8000:8000" \
  -v ./config.yml:/leaveme_config.yml \
  ghcr.io/vaibhavpandeyvpz/leaveme:latest \
  leaveme --config=/leaveme_config.yml

You can also use below Nginx vhost config to expose the server to internet easily:

server {
    listen 80;
    listen [::]:80;

    server_name example.com;

    location ~ ^/leaveme/ {
        rewrite ^/leaveme/(.*) /$1 break;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://127.0.0.1:8000;
    }
}

If not running via Docker, you can use below Supervisor configuration to run the server in daemon mode:

[program:leaveme]
autorestart=true
command=/home/ubuntu/leaveme --config=/home/ubuntu/leaveme_config.yml
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
redirect_stderr=true
stdout_logfile=/home/ubuntu/leaveme.log
stopwaitsecs=3600