Re: [PR] MINIFICPP-2296 - Install service on macOS [nifi-minifi-cpp]

2024-03-12 Thread via GitHub


martinzink closed pull request #1726: MINIFICPP-2296 - Install service on macOS
URL: https://github.com/apache/nifi-minifi-cpp/pull/1726


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] MINIFICPP-2296 - Install service on macOS [nifi-minifi-cpp]

2024-02-15 Thread via GitHub


adamdebreceni commented on code in PR #1726:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1726#discussion_r1490763055


##
bin/minifi.sh:
##
@@ -94,39 +105,93 @@ uninstall() {
 systemctl daemon-reload
 }
 
-check_service_installed() {
+check_service_installed_linux() {
 if [ ! -f "/usr/local/lib/systemd/system/minifi.service" ]; then
 echo "MiNiFi is not installed as a service. Please run 'minifi.sh 
install' first."
 exit 1
 fi
 }
 
+install() {
+echo "Uninstalling any previous versions"
+uninstall
+
+detectOS
+if [ "${darwin}" = "true"  ]; then
+  install_macos
+else
+  install_linux
+fi
+}
+
+uninstall() {
+detectOS
+if [ "${darwin}" = "true"  ]; then
+  uninstall_macos
+else
+  uninstall_linux
+fi
+}
+
+check_service_installed() {
+detectOS
+if [ "${darwin}" = "true"  ]; then
+  check_service_installed_macos
+else
+  check_service_installed_linux
+fi
+}
+
+start_service() {
+check_service_installed
+if [ "${darwin}" = "true"  ]; then
+  launchctl start org.apache.nifi.minifi
+else
+  systemctl start minifi.service
+fi
+echo "MiNiFi started"
+}
+
+stop_service() {
+check_service_installed
+if [ "${darwin}" = "true"  ]; then
+  launchctl stop org.apache.nifi.minifi
+else
+  systemctl stop minifi.service
+fi
+echo "MiNiFi stopped"
+}
+
+status_service() {
+check_service_installed
+if [ "${darwin}" = "true"  ]; then
+  launchctl list | grep org.apache.nifi.minifi
+else
+  systemctl status minifi.service
+fi
+}
+
 case "$1" in
 start)
-  check_service_installed
-  systemctl start minifi.service
-  echo "MiNiFi started"
+  start_service
   ;;
 stop)
-  check_service_installed
-  systemctl stop minifi.service
-  echo "MiNiFi stopped"
+  stop_service
   ;;
 run)
   exec "${minifi_executable}"
   ;;
 status)
-  check_service_installed
-  systemctl status minifi.service
+  status_service
   ;;
 restart)
-  check_service_installed
-  systemctl restart minifi.service
+  stop_service
+  start_service

Review Comment:
   restored 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] MINIFICPP-2296 - Install service on macOS [nifi-minifi-cpp]

2024-02-14 Thread via GitHub


szaszm commented on code in PR #1726:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1726#discussion_r1489830838


##
bin/minifi.sh:
##
@@ -94,39 +105,93 @@ uninstall() {
 systemctl daemon-reload
 }
 
-check_service_installed() {
+check_service_installed_linux() {
 if [ ! -f "/usr/local/lib/systemd/system/minifi.service" ]; then
 echo "MiNiFi is not installed as a service. Please run 'minifi.sh 
install' first."
 exit 1
 fi
 }
 
+install() {
+echo "Uninstalling any previous versions"
+uninstall
+
+detectOS
+if [ "${darwin}" = "true"  ]; then
+  install_macos
+else
+  install_linux
+fi
+}
+
+uninstall() {
+detectOS
+if [ "${darwin}" = "true"  ]; then
+  uninstall_macos
+else
+  uninstall_linux
+fi
+}
+
+check_service_installed() {
+detectOS
+if [ "${darwin}" = "true"  ]; then
+  check_service_installed_macos
+else
+  check_service_installed_linux
+fi
+}
+
+start_service() {
+check_service_installed
+if [ "${darwin}" = "true"  ]; then
+  launchctl start org.apache.nifi.minifi
+else
+  systemctl start minifi.service
+fi
+echo "MiNiFi started"
+}
+
+stop_service() {
+check_service_installed
+if [ "${darwin}" = "true"  ]; then
+  launchctl stop org.apache.nifi.minifi
+else
+  systemctl stop minifi.service
+fi
+echo "MiNiFi stopped"
+}
+
+status_service() {
+check_service_installed
+if [ "${darwin}" = "true"  ]; then
+  launchctl list | grep org.apache.nifi.minifi
+else
+  systemctl status minifi.service
+fi
+}
+
 case "$1" in
 start)
-  check_service_installed
-  systemctl start minifi.service
-  echo "MiNiFi started"
+  start_service
   ;;
 stop)
-  check_service_installed
-  systemctl stop minifi.service
-  echo "MiNiFi stopped"
+  stop_service
   ;;
 run)
   exec "${minifi_executable}"
   ;;
 status)
-  check_service_installed
-  systemctl status minifi.service
+  status_service
   ;;
 restart)
-  check_service_installed
-  systemctl restart minifi.service
+  stop_service
+  start_service

Review Comment:
   I'd prefer to keep this as a `systemctl restart` command on linux. I'd add a 
restart_service function, similar to the rest, that does `systemctl restart` on 
linux, and falls back to stop+start on other OSes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[PR] MINIFICPP-2296 - Install service on macOS [nifi-minifi-cpp]

2024-02-14 Thread via GitHub


adamdebreceni opened a new pull request, #1726:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1726

   Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
   
   - [ ] Does your PR title start with MINIFICPP- where  is the JIRA 
number you are trying to resolve? Pay particular attention to the hyphen "-" 
character.
   
   - [ ] Has your PR been rebased against the latest commit within the target 
branch (typically main)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the LICENSE file?
   - [ ] If applicable, have you updated the NOTICE file?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which 
it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI 
results for build issues and submit an update to your PR as soon as possible.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org