systemctl et MyController
-
hello
how to launch automatically the shell script of MyC at startup.
- create a service file :
sudo nano /lib/systemd/system/mycontroller.service
[Service] Description=MyController V2 Type=oneshot RemainAfterExit=yes ExecStart=/opt/apps/mycontroller/mcctl.sh start ExecStop=/opt/apps/mycontroller/mcctl.sh stop [Install] WantedBy=multi-user.target- Enable the service
sudo systemctl enable mycontroller.service
and well it doesn't work

a copy of the status :
.. sudo systemctl status mycontroller.service â mycontroller.service Loaded: loaded (/lib/systemd/system/mycontroller.service; enabled; vendor preset: enabled) Active: active (exited) since Sun 2022-11-06 11:46:37 CET; 16min ago Process: 1712 ExecStart=/opt/apps/mycontroller/mcctl.sh start (code=exited, status=0/SUCCESS) Main PID: 1712 (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 1992) Memory: 20.1M CGroup: /system.slice/mycontroller.service nov. 06 11:46:37 odroidc2 systemd[1]: Starting mycontroller.service... nov. 06 11:46:37 odroidc2 mcctl.sh[1712]: start command issued to the MyController server nov. 06 11:46:37 odroidc2 systemd[1]: Started mycontroller.service.but MyController is not running

you need to run this command to start it up
sudo /opt/apps/mycontroller/mcctl.sh startjkandasa if you pass by, tell me everything
Re-Edit
For those who do not have the courage to go to the end of the thread, the solution given by jkandas[Unit] Requires=influxdb.service After=influxdb.service [Service] Description=MyController V2 Type=oneshot RemainAfterExit=yes ExecStart=/opt/apps/mycontroller/mcctl.sh start ExecStop=/opt/apps/mycontroller/mcctl.sh stop [Install] WantedBy=multi-user.target - create a service file :
-
@JeeLet I am unable to reproduce this issue. If you are trying to access mycontroller from external system, enable the port 8080 and/or 8443 on your host firewall.
Service status
[root@fedora-vm ~]# systemctl status mycontroller â mycontroller.service Loaded: loaded (/usr/lib/systemd/system/mycontroller.service; enabled; vendor preset: disabled) Active: active (exited) since Wed 2022-11-09 13:24:03 IST; 3min 28s ago Process: 3973 ExecStart=/opt/apps/mycontroller/mcctl.sh start (code=exited, status=0/SUCCESS) Main PID: 3973 (code=exited, status=0/SUCCESS) Tasks: 9 (limit: 4653) Memory: 34.4M CPU: 221ms CGroup: /system.slice/mycontroller.service ââ 3981 ./mycontroller-server -config ./mycontroller.yaml Nov 09 13:24:03 fedora-vm systemd[1]: Starting mycontroller.service... Nov 09 13:24:03 fedora-vm mcctl.sh[3973]: start command issued to the MyController server Nov 09 13:24:03 fedora-vm systemd[1]: Finished mycontroller.service.Access MyController server
[root@fedora-vm ~]# curl http://localhost:8080/api/status -v * Trying 127.0.0.1:8080... * Connected to localhost (127.0.0.1) port 8080 (#0) > GET /api/status HTTP/1.1 > Host: localhost:8080 > User-Agent: curl/7.82.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < Content-Type: application/json < Vary: Accept-Encoding < Vary: Origin < Date: Wed, 09 Nov 2022 07:57:34 GMT < Content-Length: 307 < * Connection #0 to host localhost left intact {"hostname":"","documentationUrl":"","login":{"message":"Default username and password to login: \u003cb\u003eadmin\u003c/b\u003e / \u003cb\u003eadmin\u003c/b\u003e","serverMessage":""},"startTime":"0001-01-01T00:00:00Z","serverTime":"0001-01-01T00:00:00Z","uptime":0,"metricsDBDisabled":true,"language":""}Verify MyController server is running
[root@fedora-vm ~]# ps -ef | grep mycontroller root 3981 1 0 13:24 ? 00:00:00 ./mycontroller-server -config ./mycontroller.yaml root 4111 3650 0 13:29 pts/1 00:00:00 grep --color=auto mycontroller [root@fedora-vm ~]# tail -f /opt/apps/mycontroller/logs/mycontroller.log # enabled: false # #=========================================================================================================# 2022-11-09T13:24:04.127+0530 info handler/service_listener.go:33 handler service filter config {"filter": {"Disabled":false,"MatchAll":false,"Types":[],"IDs":[],"Labels":{"location":"server"}}} 2022-11-09T13:24:04.128+0530 info gateway/listener.go:32 gateway service filter config {"filter": {"Disabled":false,"MatchAll":false,"Types":[],"IDs":[],"Labels":{"location":"server"}}} 2022-11-09T13:24:04.130+0530 info handler/handler.go:110 secure share directory included {"directory": "mc_home/secure_share", "handlerPath": "/secure_share"} 2022-11-09T13:24:04.130+0530 info handler/handler.go:115 insecure share directory included {"directory": "mc_home/insecure_share", "handlerPath": "/insecure_share"} 2022-11-09T13:24:04.130+0530 info listener/listener.go:32 web console direcory location {"web_directory": "web_console"} 2022-11-09T13:24:04.130+0530 info listener/listener.go:64 listening HTTPS/SSL service on {"address": "0.0.0.0:8443"} 2022-11-09T13:24:04.130+0530 info listener/listener.go:44 listening HTTP service on {"address": "0.0.0.0:8080"} -
.... jkandasa thanks for the help
here are the messages in two parts- reboot of the system for an automatic launch of MyC
- and manual launch with the command line
browser logout: This site canât be reached192.16xxxx refused to connect.SERVICE STATUS
...@odroidc2:~$ systemctl status mycontroller â mycontroller.service - MyController V2 Loaded: loaded (/lib/systemd/system/mycontroller.service; enabled; vendor pre Active: active (exited) since Wed 2022-11-09 09:17:05 CET; 14min ago Process: 1694 ExecStart=/bin/bash /opt/apps/mycontroller/mcctl.sh start (code= Main PID: 1694 (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 1992) Memory: 20.1M CGroup: /system.slice/mycontroller.service nov. 09 09:17:05 odroidc2 systemd[1]: Starting MyController V2... nov. 09 09:17:05 odroidc2 bash[1694]: start command issued to the MyController s nov. 09 09:17:05 odroidc2 systemd[1]: Started MyController V2.ACCESS MYCONTROLLER SERVER
...@odroidc2:~$ curl http://localhost:8080/api/status -v * Expire in 0 ms for 6 (transfer 0xaaaadeeb5d60) * Expire in 1 ms for 1 (transfer 0xaaaadeeb5d60) * Expire in 0 ms for 1 (transfer 0xaaaadeeb5d60) * Expire in 2 ms for 1 (transfer 0xaaaadeeb5d60) * Ex...... ........... .........ransfer 0xaaaadeeb5d60) * Expire in 2 ms for 1 (transfer 0xaaaadeeb5d60) * Expire in 0 ms for 1 (transfer 0xaaaadeeb5d60) * Expire in 0 ms for 1 (transfer 0xaaaadeeb5d60) * Expire in 2 ms for 1 (transfer 0xaaaadeeb5d60) * Expire in 1 ms for 1 (transfer 0xaaaadeeb5d60) * Expire in 1 ms for 1 (transfer 0xaaaadeeb5d60) * Expire in 1 ms for 1 (transfer 0xaaaadeeb5d60) * Trying ::1... * TCP_NODELAY set * Expire in 149998 ms for 3 (transfer 0xaaaadeeb5d60) * Expire in 200 ms for 4 (transfer 0xaaaadeeb5d60) * connect to ::1 port 8080 failed: Connexion refusée * Trying 127.0.0.1... * TCP_NODELAY set * Expire in 149997 ms for 3 (transfer 0xaaaadeeb5d60) * connect to 127.0.0.1 port 8080 failed: Connexion refusée * Failed to connect to localhost port 8080: Connexion refusée * Closing connection 0 curl: (7) Failed to connect to localhost port 8080: Connexion refuséeVERIFY MYCONTROLLER SERVER IS RUNNING
... @odroidc2:~$ ps -ef | grep mycontroller "name" 2609 2593 0 09:35 pts/0 00:00:00 grep mycontroller ... @odroidc2:~$ tail -f /opt/apps/mycontroller/logs/mycontroller.log 2022-11-09T09:24:15.244+0100 info gateway/service.go:35 starting a gateway {"id": "GwRs485"} 2022-11-09T09:24:15.245+0100 info protocol_serial/client.go:63 opening a serial port {"gateway": "GwRs485", "port": "/dev/ttyACM0"} 2022-11-09T09:24:15.245+0100 error provider/service.go:86 error {"error": "open /dev/ttyACM0: no such file or directory"} 2022-11-09T09:24:15.245+0100 error gateway/service.go:44 failed to start a gateway {"id": "GwRs485", "timeTaken": "1.771339ms", "error": "open /dev/ttyACM0: no such file or directory"} 2022-11-09T09:17:05.711+0100 info logger/load.go:15 welcome to the MyController world :) 2022-11-09T09:17:05.733+0100 info mcbus/client.go:48 bus service paused 2022-11-09T09:17:05.736+0100 info backup/restore.go:149 Executing import job {"sourceDir": "mc_home/data/storage/memory_db/yaml", "fileType": "yaml"} 2022-11-09T09:17:06.083+0100 info mcbus/client.go:54 bus service resumed 2022-11-09T09:17:06.099+0100 error influxdb_v2/client.go:206 error on getting ping status {"error": "Get \"http://127.0.0.1:8086/ping\": dial tcp 127.0.0.1:8086: connect: connection refused"} 2022-11-09T09:17:06.099+0100 fatal server/start.go:39 error on init metric database {"error": "Get \"http://127.0.0.1:8086/ping\": dial tcp 127.0.0.1:8086: connect: connection refused"} -
manual launch
.....@odroidc2:~$ sudo /opt/apps/mycontroller/mcctl.sh start [sudo] Mot de passe de "name"Â :Â start command issued to the MyController serverSERVICE STATUS
... @odroidc2:~$ systemctl status mycontroller â mycontroller.service - MyController V2 Loaded: loaded (/lib/systemd/system/mycontroller.service; enabled; vendor preset: enabled) Active: active (exited) since Wed 2022-11-09 09:17:05 CET; 20min ago Process: 1694 ExecStart=/bin/bash /opt/apps/mycontroller/mcctl.sh start (code=exited, status=0/SUCCESS) Main PID: 1694 (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 1992) Memory: 20.1M CGroup: /system.slice/mycontroller.service nov. 09 09:17:05 odroidc2 systemd[1]: Starting MyController V2... nov. 09 09:17:05 odroidc2 bash[1694]: start command issued to the MyController server nov. 09 09:17:05 odroidc2 systemd[1]: Started MyController V2.ACCESS MYCONTROLLER SERVER
... @odroidc2:~$ curl http://localhost:8080/api/status -v * Expire in 0 ms for 6 (transfer 0xaaaae49aad60) * Expire in 1 ms for 1 (transfer 0xaaaae49aad60) ..... ... * Expire in 1 ms for 1 (transfer 0xaaaae49aad60) * Expire in 1 ms for 1 (transfer 0xaaaae49aad60) * Trying ::1... * TCP_NODELAY set * Expire in 149998 ms for 3 (transfer 0xaaaae49aad60) * Expire in 200 ms for 4 (transfer 0xaaaae49aad60) * Connected to localhost (::1) port 8080 (#0) > GET /api/status HTTP/1.1 > Host: localhost:8080 > User-Agent: curl/7.64.0 > Accept: */* > < HTTP/1.1 200 OK < Content-Type: application/json < Vary: Accept-Encoding < Vary: Origin < Date: Wed, 09 Nov 2022 08:39:05 GMT < Content-Length: 313 < * Connection #0 to host localhost left intact {"hostname":"","documentationUrl":"","login":{"message":"Default username and password to login: \u003cb\u003eadmin\u003c/b\u003e / \u003cb\u003eadmin\u003c/b\u003e","serverMessage":""},"startTime":"0001-01-01T00:00:00Z","serverTime":"0001-01-01T00:00:00Z","uptime":0,"metricsDBDisabled":false,"language":"en_GB"}mci@odroidc2:~$VERIFY MYCONTROLLER SERVER IS RUNNING
..... @odroidc2:~$ ps -ef | grep mycontroller root 2624 1 1 09:37 pts/0 00:00:03 ./mycontroller-server -config ./mycontroller.yaml mci 2646 2593 0 09:41 pts/0 00:00:00 grep mycontroller ....@odroidc2:~$ tail -f /opt/apps/mycontroller/logs/mycontroller.log 2022-11-09T09:37:14.195+0100 info gateway/service.go:35 starting a gateway {"id": "GwRs485"} 2022-11-09T09:37:14.196+0100 info protocol_serial/client.go:63 opening a serial port {"gateway": "GwRs485", "port": "/dev/ttyACM0"} 2022-11-09T09:37:14.203+0100 info handler/handler.go:106 secure share directory included {"directory": "mc_home/secure_share", "handlerPath": "/secure_share"} 2022-11-09T09:37:14.203+0100 info handler/handler.go:111 insecure share directory included {"directory": "mc_home/insecure_share", "handlerPath": "/insecure_share"} 2022-11-09T09:37:14.203+0100 info listener/listener.go:32 web console direcory location {"web_directory": "web_console"} 2022-11-09T09:37:14.203+0100 info gateway/service.go:48 started a gateway {"id": "GwRs485", "timeTaken": "8.465971ms"} 2022-11-09T09:37:14.204+0100 info listener/listener.go:64 listening HTTPS/SSL service on {"address": "0.0.0.0:8443"} 2022-11-09T09:37:14.204+0100 info listener/listener.go:44 listening HTTP service on {"address": "0.0.0.0:8080"} 2022-11-09T09:37:14.204+0100 info gateway/service.go:35 starting a gateway {"id": "OdroidC2"} 2022-11-09T09:37:14.439+0100 info gateway/service.go:48 started a gateway {"id": "OdroidC2", "timeTaken": "234.218179ms"} -
@JeeLet can you stop and start the service manually?
systemctl stop mycontroller systemctl start mycontrollerIf it works you have to add influxdb as dependent service for MyController service.
My assumption: On boot influxdb is not ready and MyController service terminated -
yes it works fine
it asks me the password.so I just have to add a timeout in the file, or even better check the start of influxdb ?
@odroidc2:~$ systemctl stop mycontroller ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === Authentification requise pour arrĂȘter « mycontroller.service ». Authenticating as: ... "..name" Password: ==== AUTHENTICATION COMPLETE === @odroidc2:~$ systemctl start mycontroller ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === Authentification requise pour dĂ©marrer « mycontroller.service ». Authenticating as: ...."name" Password: ==== AUTHENTICATION COMPLETE ===test
[Unit] Requires=influxdb@client.service After=influxdb@client.service?????
-
@JeeLet you can add
influxdb.serviceas dependency.can you add the following lines on mycontroller.service file and try on boot?
[Unit] Requires=influxdb.service After=influxdb.service [Service] Description=MyController V2 Type=oneshot RemainAfterExit=yes ExecStart=/opt/apps/mycontroller/mcctl.sh start ExecStop=/opt/apps/mycontroller/mcctl.sh stop [Install] WantedBy=multi-user.target -
it's maximum super good

after cleaning the old one
"sudo systemctl revert mycontroller.service"and a copy of the example you gave me (thanks)
"sudo systemctl enable mycontroller.service"a reboot, functional server connection

... well I continue with MyController, other things to see.
Thanks a lot, lots of sunshine for you
