c/c++ Controlling Linux service in my app - c++

I want to start or stop mariadb in my app.
So, I am just using
system("systemctl start mariadb.service");
But it does not work.
Error is:
Error creating textual authentication agent: Error opening current controlling terminal for the process (`/dev/tty'): No such device or address (polkit-error-quark, 0)
What should I do?
My app runs with root and daemon
Thanks.

Related

Couldn't connect web socket client to websocket server on local host windows 10

I have an application signed for microsoft store which starts a web socket server on localhost (0.0.0.0:8081) on launching. Then I run python script with websocket client on the same host and try to connect to server (ws://127.0.0.1:8081) and it couldn't connect. But I can connect without any problems if I run this python script from another PC. Actually it works fine on local PC on another platforms: Win7, MacOS.
What i tried:
disabled windows firewall and defender
tried to add exception for application using CheckNetIsolation LoopbackExempt
tried to connect using different ip (0.0.0.0, 127.0.0.1, pc name)
It seems like I have to switch/set on/off some option for application or win10, but I can't find it
Thanks for help in advance
I found a solution https://learn.microsoft.com/en-us/windows/iot-core/develop-your-app/loopback
if you want to connect smth to win application on win 10 you should run
CheckNetIsolation.exe LoopbackExempt -is -n=your application
permanently
the best way to add it to start up menu

Error: connect ECONNREFUSED 127.0.0.1:3306 when using cloud sql for MYSQL from NodeJS app

I followed all the steps mentioned in this sample app link. GitHubLink. When running the script (npm run init-cloudsql) to initialize mysql database, I get an error below:
D:\gcloud\nodejs-getting-started\2-structured-data\books\model-cloudsql.js:143
throw err;
^
Error: connect ECONNREFUSED 127.0.0.1:3306
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
--------------------
at Protocol._enqueue (D:\gcloud\nodejs-getting-started\2-structured- data\node_modules\mysql\lib\protocol\Protocol.js:145:48)
at Protocol.handshake (D:\gcloud\nodejs-getting-started\2-structured-data\node_modules\mysql\lib\protocol\Protocol.js:52:23)
at Connection.connect (D:\gcloud\nodejs-getting-started\2-structured-data\node_modules\mysql\lib\Connection.js:130:18)
at Connection._implyConnect (D:\gcloud\nodejs-getting-started\2-structured-data\node_modules\mysql\lib\Connection.js:461:10)
at Connection.query (D:\gcloud\nodejs-getting-started\2-structured-data\node_modules\mysql\lib\Connection.js:206:8)
at createSchema (D:\gcloud\nodejs-getting-started\2-structured-data\books\model-cloudsql.js:126:14)
at prompt.get (D:\gcloud\nodejs-getting-started\2-structured-data\books\model-cloudsql.js:117:5)
at D:\gcloud\nodejs-getting-started\2-structured-data\node_modules\prompt\lib\prompt.js:336:32
at D:\gcloud\nodejs-getting-started\2-structured-data\node_modules\utile\node_modules\async\lib\async.js:154:25
at assembler (D:\gcloud\nodejs-getting-started\2-structured-data\node_modules\prompt\lib\prompt.js:333:9)
What am i missing? I could not resolve this error. Can someone help me fix this issue?
This error occurs when you run an instance of PopSQL or Node.js and the MySQL server is not running on your local machine.
Try the below steps
Press Windows key and R on your keyboard. This opens the command prompt
Type in services.msc and click ok.
In the services pop up , check for MYSQL57. If its not in the running state, Click on run this service in the left column of the dialog box
Once the service is running connect to the POPSQL from the connections window
The error message you shared indicates your machine could not connect to the instance's IP address on port 3307 (which is used by the proxy). I tested this on my own machine, and it is listening there. This likely indicates a firewall on your machine or your local network that is preventing outbound connections on port 3307. Try and open this in the firewall, and see if you can connect.
You need to whitelist your IP to access Cloud SQL. https://cloud.google.com/sql/docs/mysql/instance-access-control

wildfly 10 unexpected shutdown often

Currently i have issue.
application server (wildfly 10) unexpected shutdown often.  
so i have check the server log nothing is there about the shutdown.
application running in aws(amazon web services).
application server name -wildfly 10.
am using putty to start the application(remote session)
server start command /usr/share/wildfly/bin/standalone.sh &
once i start i will close the putty.
i have place & symbol in start command so it will run in background, but after few days it's unexpected shutdown and nothing is there in server log.
thanks in advance
When you start applications from a command line on any unix based OS, it will be terminated automatically when the terminal session is closed, unless you tell the OS not to do that:
some-aws-prompt$ nohup /usr/share/wildfly/bin/standalone.sh &
The nohup command is an abbreviation for "don't hang up (the phone)" or "no hang up" when the user logs out.

Weblogic 12 remote debug

I want to connect to Weblogic from IDE in remote debug mode. I have added set JAVA_OPTIONS=-Xdebug -Xrunjdwp:transport=dt_socket,address=54840,suspend=n,server=y
to startWebLogic.cmd. After the start the weblogic server print out Listening for transport dt_socket at address: 54840. But when I try to connect I get an error:
Unable to open debugger port : java.net.ConnectException "Connection refused: connect"
I checked the remote debug on 54840 port with Apache Tomcat and everything is good. Please, tell me what is wrong with Weblogic.
WebLogic Server Version: 12.1.2.0.0 development mode.
Check the position of this added message. Noticed in File startWeblogic.cmd,
set DOMAIN_HOME=C:\Oracle\Middleware\Oracle_Home\user_projects\domains\ebilling_domain
for %%i in ("%DOMAIN_HOME%") do set DOMAIN_HOME=%%~fsi
call "%DOMAIN_HOME%\bin\setDomainEnv.cmd" %*
If you add this message before the above. The message will be override by the related code in setDomainEnv.cmd.
if "%debugFlag%"=="true" (
set JAVA_DEBUG=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=%DEBUG_PORT%,server=y,suspend=n -Djava.compiler=NONE
set JAVA_OPTIONS=%JAVA_OPTIONS% %enableHotswapFlag% -ea -da:com.bea... -da:javelin... -da:weblogic... -ea:com.bea.wli... -ea:com.bea.broker... -ea:com.bea.sbconsole...
) else (
set JAVA_OPTIONS=%JAVA_OPTIONS% %enableHotswapFlag% -da
)
I have connected the remote server successfully.
Despite the fact the thread is kind of ancient, maybe I still can help a bit.
It seems weblogic comes ready to run in debug mode. I was able to use it setting the following environment variable:
Windows powershwell
$env:debugFlag = 'true'
Linux
export debugFlag=true
It happens that weblogic start scripts come ready to use this variable and it sets port 8453 as default for you to attach your debugger (probably with any moddern IDE).
If you still need to change that default port you can use another env variable (follow the above patterns for windows ad linux):
DEBUG_PORT = 54840
This way you probably wont have to mess with weblogic scripts.
I'm using weblogic 12c (12.1.3), folowing this article, and it worked fine for my case: https://www.linkconsulting.com/oracle/weblogic-remote-debugging-using-jdeveloper
Regards!

Problems getting RabbitMQ and Django-Celery Running: Target Machine actively refused connection

I am trying to get Django-Celery running on my Django App. I cannot get the worker server to run. When I try I get the message: No Connection could be made because the target machine actively refused it
Here is what I have done so far. First, I installed the django celery package: http://pypi.python.org/pypi/django-celery
I can load it into python without problems. I also installed the RabbitMQ server per the windows install instructions: http://www.rabbitmq.com/install.html#windows
Starting the tutorials in pytho on the RabbitMQ site I saw the need to install pika: http://pypi.python.org/pypi/pika. It imports without any problems.
From there I start the RabbitMQ server by running this at the command line: rabbitmq-service start
I get the message back that Service RabbitMQ started
Here is where I start to have problems.
I attempted the first steps in django-celery: http://packages.python.org/django-celery/getting-started/first-steps-with-django.html and the "hello world" example on the rabbitMQ site: http://www.rabbitmq.com/tutorials/tutorial-one-python.html
In both cases I get the message: No Connection could be made because the target machine actively refused it
My first thought was that this sounded like a firewall problem. So I went into the windows 7 firewall and added inbound and outbound rules to open the local and remote ports 5672 and 5673 to TCP protocol, but I still get the same error message.
When I run rabbitmqctl status i get the message:
Error: unable to connect to node 'rabbit#hostname': nodedown
diagnostics:
- nodes and their ports on hostname: [{rabbitmqctl18856, 505031}]
Does that mean it that it is trying to operate on those ports? what about the default 5672?
Any suggestions?
UPDATE: This was actually a problem resulting from several failed rabbitmq installs conflicting with the latest installation. If you have to remove rabbitmq use the 'rabbitmq-service remove' command and not SC DELETE, which cause a lot of problems for me and I had to go in and clean up my windows registry file.
The nodedown error indicated by rabbitmqctl suggests that the server isn't running on that machine.
Try going though the steps in RabbitMQ's troubleshooting guide. In particular, pay close attention to the logs. Has the server crashed for some reason? Could you post the logs somewhere?