systemctl showing different behaviour of binary - systemd

I have developed one OTA(Over The Air) manager which uses "swupdate" command internally to update the firmware. This swupdate is applied by "system()" function inside OTA manager code.
My binary is working as expected and "swupdate" command is working fine if I run my binary ota_manager directly from console.
I have created one systemctl service for my binary as below:
[Unit]
Description=OTA manager service
After=syslogd.service
[Service]
Type=simple
ExecStart=/usr/bin/ota_manager
[Install]
WantedBy=multi-user.target
If I run this service, swupdate command is always failing with error:
SWUPDATE failed [0] ERROR handlers/archive_handler.c : extract : 110 : archive_read_next_header(): Pathname can't be converted from UTF-8 to current locale
I am checking swupdate error but I don't think it is a swupdate issue as it is working fine if I apply the command manually on the console or I run ota_manager binary directly from the console.
It is looking like systemctl is creating the issue.
I am using NXP IMX6ULL based custom hardware with hardknott version Yocto OS(5.10 kernel).
Note: I have validated same with warrior version Yocto OS(4.19 kernel) and same code is working fine with systemctl service as well.
Do anyone has any pointers here?

Found root cause:
"swupdate" command requires "locale" settings to be set as environment variables so if they are not set it gives such kind of error.
In my gateway, that environment variables were set as a custom profile of console. So swupdate command works fine from console
If swupdate command provided as "system()" call from application, it was running in background sub shell in which this custom profile was not loaded and so "locale" environment variables were not present.

Related

Docker Windows and Linux Containers Simultaneously

How Docker Windows and Linux Containers run Simultaneously (how does it works) and why building doesn't work.
I try to run mixed windows and linux containers using docker compose.
I followed this
article and its worked (using compose version 2.4 and latest docker desktop).
Can someone explain me how does it work? Does it work only with wsl or I can use it using linux hyperv?
When I try to build new linux image (pulling works fine) I got an error, some commands gave me Invalid signal: WINCH and some gave me
returned a non-zero code: 4294967295:
failed to shutdown container: container ad12191abf0849d5e49bb5dc0570d6ba8eaf2cc5b4e7d77127ed381901fcb672
encountered an error during hcsshim::System::waitBackground: failure in a Windows system call:
The virtual machine or container with the specified identifier is not running. (0xc0370110):
subsequent terminate failed container ad12191abf0849d5e49bb5dc0570d6ba8eaf2cc5b4e7d77127ed381901fcb672
encountered an error during hcsshim::System::waitBackground: failure in a Windows system call:
The virtual machine or container with the specified identifier
Someone solved it?

How to Set the Correct Permissions to Launch Neo4J on AWS EC2 via Its Bash Script?

I'm trying to launch Neo4J graph database on AWS using their AIM image (enteprise 3.3.9)
However, the server fails to launch the instance automatically how it's supposed to.
When I try to relaunch it using
systemctl restart neo4j
It also fails.
When I do
systemctl cat neo4j
I find the /etc/neo4j/pre-neo4j.sh file, which is apparently launched on the instance's startup, which, in turn launches Neo4J (when it's supposed to work):
[Unit]
Description=Neo4j Graph Database
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/etc/neo4j/pre-neo4j.sh
Restart=on-failure
User=neo4j
Group=neo4j
Environment="NEO4J_CONF=/etc/neo4j" "NEO4J_HOME=/var/lib/neo4j"
LimitNOFILE=60000
TimeoutSec=120
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
So then I launch it manually via the bash script using the sudo prefix and then it starts up fine.
sudo /etc/neo4j/pre-neo4j.sh
The documentation on deploying Neo4J on an AWS server doesn't mention anything about permissions if you use their image. So what can be the problem?
I don't want to have manually launch the DB using the sudo — is it possible to resolve this problem by modifying the bash script itself?
..
The file /etc/neo4j/pre-neo4j.sh sets some environmental parameters and then launches neo4j via:
/usr/share/neo4j/bin/neo4j console
Based on the comments.
The solution was to use
journalctl -u neo4j
to inspect the logs associated with the failed start of neo4j. This enabled to identify the root cause, and subsequently, to fix the issue.

Embedded Postgres cannot obtain process PID on Mac OS

I'm using embedded PostgreSQL with Java 11 for integration testing. On Windows it runs fine, but on Mac it first downloads Mac OS binaries (which is expected):
Extract /Users/fubar/.embedpostgresql/postgresql-11.1-1-osx-binaries.zip START
But then it fails with the following stacktrace:
java.lang.NoSuchFieldException: handle
at java.base/java.lang.Class.getDeclaredField(Class.java:2411)
at de.flapdoodle.embed.process.runtime.Processes.windowsProcessId(Processes.java:109)
at de.flapdoodle.embed.process.runtime.Processes.access$200(Processes.java:51)
at de.flapdoodle.embed.process.runtime.Processes$PidHelper$2.getPid(Processes.java:209)
When I look into Processes source code I see that internally it uses PidHelper.LEGACY, that fails the first attempt to obtain pid via unixLikeProcessId().
Could anyone, please, give a hint why this is happenning or how to fix that?
Logs revealed the following:
Possibly failed to run initdb:
initdb: invalid locale name "en-US"
So the initdb failed, PostgeSQL instance didn't start and didn't create a postmaster.pid file, which all led to the error above.
The problem was in locale that was configured via additionalInitDbParams=[--locale=en-US, -EUTF8].

Error configuring wildfly as a windows service

I am using wildfly 10.1 in standalone mode and need to use it as a service.
I copied the service files to the bin folder and then installed the service from the command prompt.
This works well, except that it is impossible to stop the service without killing the process using taskkill.
As a fix, I tried replacing
set DESCRIPTION="WildFly Application Server"
with
set DESCRIPTION=WildFly Application Server
in the service.bat file as mentioned here. But this is causing the service not to start. The system log says:
The Wildfly service terminated with the following service-specific
error: Incorrect function.
How can I fix this issue and get the service starting and stoppping normally?
Add System variable JAVA_HOME to System variable and try to start the service. It worked for me.

Smartfoxserver 2X linux 64 running on EC2 via dotcloud - how to install?

I am currently trying to deploy smartfoxserver 2X on EC2 using dotcloud. I have been able to detect the private ip of the amazon web instance, and using the dotcloud tools I have been able to determine the correct port. However, I have difficulty installing the server proper via the command line so that I can log into it using the AdminTool.
My postinstall is fairly straightforward:
./SFS2X/sfs2x-service start-launchd
I find that on 'dotcloud push' there is a fair amount of promising output in my cygwin terminal, but the push hangs after saying that the sfs2x-service has been launched correctly, until timeout.
Consequently, my question is, has anyone found a way to install SFS2X on EC2 via dotcloud successfully? I managed to have partial success with SFS Pro, with a complete push to dotcloud, by calling ./jre/bin/java -jar installer.jar in my postinstall. Do I need to do extra legwork and build an installer jar for SFS2X? Is there a way that would be best to do this?
I do understand that there is a standard approach to deployment with SFS2X using RightScale on EC2, however I am interested in deployment using the dotcloud platform.
Thanks in advance.
The reason why it is hanging is because you are trying to start your process in the postinstall, and this is not the correct place to do that. The postinstall script is suppose to finish, if it doesn't the deployment will time out, and then get cancelled.
Once the postinstall script is finished, it will then finish the rest of your deployment.
See this page for more information about dotCloud postinstall script:
http://docs.dotcloud.com/0.9/guides/hooks/#post-install
Pay attention to this warning at the end.
Warning:
If your post-install script returns an error (non-zero exit code), or if it runs for more than 10 minutes, the platform will consider that your build has failed, and the new version of your code will not be deployed.
Instead of putting this in the postinstall script, you should add it as a background process, so that it starts up once the deployment process is complete.
See this page for more information on adding background processes to dotCloud services:
http://docs.dotcloud.com/0.9/guides/daemons/
TL;DR: You need to create a supervisord.conf file, and add it to the root of your project, and add your service to that.
Example (you will need to change to fit your situation):
[program:smartfoxserver]
command = /home/dotcloud/current/SFS2X/sfs2x-service start-launchd
Also, make sure you have the correct dotCloud service specified in your dotcloud.yml in order to have the correct binary and libraries installed for what your smartfoxserver application.

Resources