Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restart_services.sh: restart pipeline service when .env file changes #380

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

JenySadadia
Copy link
Collaborator

@JenySadadia JenySadadia commented Jan 3, 2024

Environment variable KCI_API_TOKEN is required to run pipeline services. The variable is defined in .env file. Add a script to monitor .env file using inotifywait tool. If the file changes are detected, that is if the token is modified, restart all the services.

@JenySadadia
Copy link
Collaborator Author

inotifywait perfectly detects changes when tested with nano and visual studio editors.
I have monitored closed_write event for file changes that will detect when a file is closed after being opened in writable mode.

The script did not work with vim though. I investigated and the reason is, vim does not overwrite a file. Instead when a file is modified, it creates a new file, writes content to it, then deletes the old file and moves the new file with the old file name. That's why the tool is not able to detect the file changes as the original gets deleted every time a file is modified with vim.

Hence, the script solely depends on the editor's behavior.

@JenySadadia JenySadadia requested a review from nuclearcat January 3, 2024 07:15
Copy link
Member

@nuclearcat nuclearcat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,thanks, we might evolve this script to ENTRYPOINT later on

@JenySadadia JenySadadia marked this pull request as ready for review February 20, 2024 07:25
@pawiecz
Copy link
Contributor

pawiecz commented Feb 20, 2024

I might be missing background information on requirements for this script. In case list of tracked events should be extended to also cover e.g. vim, I'd suggest entr which would also cover that (but would also require some rework in the script: ls '.env' | <loop body>).

There's a handy list of file watchers in case this topic would be revisited in future.

@JenySadadia
Copy link
Collaborator Author

@pawiecz Here is the requirements for the script #358

Environment variable `KCI_API_TOKEN` is required to run
pipeline services. The variable is defined in `.env` file.
Add a script to monitor `.env` file. If the file changes
are detected, that is if the token is modified, restart
all the services.

Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
@JenySadadia JenySadadia requested a review from a-wai March 1, 2024 05:22
@JenySadadia JenySadadia added this pull request to the merge queue Mar 1, 2024
Merged via the queue into kernelci:main with commit 282c40b Mar 1, 2024
3 checks passed
@JenySadadia JenySadadia deleted the monitor-env-file branch March 1, 2024 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants