omkarkhatavkar / jirasync

This CLI tool to sync and track GitHub issues, pr's, pr_reviews with Jira. Currently supported to only for create, update and close status.
MIT License
4 stars 3 forks source link

Add systemd unit files #4

Closed rochacbruno closed 5 years ago

rochacbruno commented 5 years ago

we need to put the workflows to run as a service, the idea is to create a point of entry in the cli code called run_as_a_service it can be a click command.

idea:

@click.command()
....
@pass_config
def run_as_a_service(...): 
    while True:
         # run github workflow
        # run redmine workflow
        sleep(60 * 15)  # 15 minutes

NOTE: which workflow to run can be read from JIRASYNC_SETTINGS_PATH/config.yaml

Then we put this to run in a systemd unit.

jirasync.service

[Unit]
Description=Jirasync
After=network-online.target
Wants=network-online.target

[Service]
Environment="JIRASYNC_SETTINGS_PATH=/etc/jirasync/"
User=$USER
WorkingDirectory=/var/run/jirasync/
RuntimeDirectory=jirasync
ExecStart=$JIRASYNC_VENV_DIR/bin/jirasync run_as_a_service 
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

The file should be deployed to /lib/systemd/system/jirasync.service we can have a script, a maketarget or ansible playbook to depploy it. Must be deployed as root and with 0644 permissions.