I have installed & configured Supervisor & Laravel-Echo-Server and i have set up a program that is supposed to continuously run a laravel-echo-server and it looks like this:
[program:laravel-echo-server]
directory=/var/www/html/laravel
command=/root/.nvm/versions/node/v10.13.0/bin/laravel-echo-server start
autostart=true
autorestart=true
redirect_stderr=true
user=root
stdout_logfile=/var/log/laravel-echo-server.log
The command line error i'm getting is: laravel-echo-server: ERROR (spawn error)
The error in the log file is: /usr/bin/env: ^^xnode ^^y: No such file or directory
What i've tried so far is:
Checked if laravel-echo-server is installed globally with npm list -g laravel-echo-server (it is).
Defined absolute path to the laravel-echo-server that looks like this:
command=/root/.nvm/versions/node/v10.13.0/bin/laravel-echo-server start --dir /var/www/html/laravel
Created a sym link for the laravel-echo-server in usr/bin, and i placed
laravel-echo-server.json files both in the sym link & in the absolute path (for testing purposes, to see if i can start the server from there - I can), again redefined the command in the program to command=laravel-echo-server start, nothing works and i'm out of ideas.
Can someone help me out with what i'm doing wrong?
P.S. Again for testing purposes, i've set up PM2 and when i run the laravel-server-echo thru it it says that it's online but it's really not, so i'm assuming that it probably encounters similar error.
I've found the solution to my problem:
ln -s /root/.nvm/versions/node/v10.13.0/bin/node /usr/bin/node
From what i understand, this is bug for Node on Debian.
Related
I am currently working on a Symfony 6 project. Now I have the situation that I want to stop and start a systemd service which is used to consume the messages from the Symfony Messenger message queue.
The service is called "messenger-worker#.service" and is located under /etc/systemd/system
Now in my PHP script I run the following:
$output = shell_exec("sudo -u www-data /usr/bin/systemctl stop messenger-worker#1.service 2>&1");
dd($output)
The $output contains the following error message:
Failed to stop messenger-worker#1.service: Interactive authentication required.
See system logs and 'systemctl status messenger-worker#1.service' for details.
Under /etc/sudoers.d I already created a file called "www-data". With the following code:
%www-data ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop messenger-worker#1.service
Does anyone have an idea what I am doing wrong here?
As #Rufinius noted in the comments. It does not make sence to try to execute the command as -u www-data. Furthermore I realized that I had to remove "2>&1" at the end of the command in order to make it work properly. I think it's because I didn't include the part ("2>&1") in my sudoers.d file in the command, but I don't need it now anyway. So I adjusted it as the following:
shell_exec("sudo /usr/bin/systemctl stop messenger-worker#1.service");
Im having an issue creating a domain on plesk, this command works fine when run through cli:
plesk bin site --create newdomain.com -webspace-name existingdomain.com -www-root /httpdocs
But when I add the same code above to a bash script (create_domain.sh) and try to run it with:
sudo bash create_domain.sh
I get the following error
An error occurred during domain creation: hosting update is failed: cObject->update() failed: Some fields are empty or contain an improper value. ('www_root' = ')
Anyone knows why this is happening?
This was because I was using windows to edit the bash file, I deleted it and rewrote it in nano and it worked
here is my problem: i would like to create a directory and limit it size using this method.
The thing is when i try it via cli its working perfectly (the file system is mounted on the newly created directory with its size limit), however when i put it in a bash script the directory is created but not with its size limit.
Here is my script.sh:
# !/bin/bash
# Set default parameters
limited_directory_name=$1
size=$2
# Setting path
parent_path="/path/to/directory/parent/"
directory_path="$parent_path$limited_directory_name"
# Creating directory/mountpoint
mkdir "$directory_path"
#Creating a file full of /dev/zero
limited_size_file="$directory_path.ext4"
touch "$limited_size_file"
dd if=/dev/zero of="$limited_size_file" bs="$size" count=1
#Formating the file
sudo mkfs.ext4 "$limited_size_file"
#Mount the disk
sudo mount -o loop,rw,usrquota,grpquota "$limited_size_file" "$directory_path"
I believe (pretty sure actually), that the problem is in these two last lines
sudo mkfs.ext4 "$limited_size_file"
or/and
sudo mount -o loop,rw,usrquota,grpquota "$limited_size_file" "$directory_path"
because as i said, the file and directory are created but just not with the size limit.
Also when i try to delete the directory ($directory_path/) after executing those command via cli i got : rm: cannot delete '$directory_path/': Device or resource busy, that i dont get when trying to delete it after executing the script. So i guess that the file system is not mounted when executing the script, and the problem is probably in the last two lines. I dont know if its has something to do with the way of using sudo inside a script or just something with mounting a file system inside a bash script.
I just wanna say that i am fairly new to bash scripting and i am sorry if my mistake is something like an obvious (noob) error. You can also say if i can improve my question in any way and i apologize if it's not clear enough.
And one last thing, i have tried different syntax for the last two line like:
sudo $(mkfs.ext4 "$limited_size_file")
or
sudo `mkfs.ext4 "$limited_size_file"`
or just
mkfs.ext4 "$limited_size_file" without sudo.
But nothing seems to work. I am using debian 10 btw and im calling the script like this in a PHP page (if it can help):
exec("myscript.sh $dname $dsize");
I am using symfony 4 with app engine flex env. I wrote a symfony console command which is meant to be running long term. Docs says that GAE has supervisord in place so I can use it to manage the script. How can I make sure the worker is actually running?
I've created the file additional-supervisord.conf with content:
[program:custom-worker]
command = php bin/console app:my-console-command
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes=0
user = www-data
autostart = true
autorestart = true
priority = 5
stopwaitsecs = 20
But I can't see anything in the log and don't know is command running properly or not. I also ssh to the instance and checked the processes - supervisord is running, but in php processes I can't see my script running. So I assume it does not work.
How can I check supervisord logs and track what's going with the worker? Would appreciate any advise.
Assuming you have stored your additional-supervisord.conf file correctly in the root of your project.
Give the full path to the console executable inside your script:
[program:custom-worker]
command = php %(ENV_APP_DIR)s/bin/console your:command
Further you can log stdout & stderr of the command to a file as follows:
[program:custom-worker]
command = php %(ENV_APP_DIR)s/bin/console custom:command 2>&1 1>%(ENV_APP_DIR)s/app/logs/custom.command.out.log
I use CakePHP (v2) Shell to execute a process behind my online application.
This Shell is part of a Plugin, so stored in:
app/Plugins/MyPlugin/Console/Command/MyScriptShell.php
I used 2 different dev servers, and everything goes well with the execution of this Shell.
Unfortunately, the execution fails on my production environment.
On a Unix terminal, if I try manually to execute the command below, it fails:
# app/Console/cake MyPlugin.MyScript helloworldfunction [params1, paramsN] -app app
PHP Fatal error: Class 'Controller' not found in /var/www/app/Controller/AppController.php on line 6
In an other side, if I execute the same command line with a "sudo -u {a-unix-user} {command}", the execution works! Here are 2 examples which work:
# sudo -u www-data app/Console/cake MyPlugin.MyScript helloworldfunction [params1, paramsN] -app app
# sudo -u root app/Console/cake MyPlugin.MyScript helloworldfunction [params1, paramsN] -app app
Ok, so noticing this behavior, I thought about a unix rights issue or something like this. I decided, as a new test, to grant a unix session of www-data in my termina to execute the same command, but without the "sudo -u {a-unix-user} {command}" directive. Unfortunately, this fails too:
# sudo su www-data
www-data# whoami
www-data
www-data# app/Console/cake MyPlugin.MyScript helloworldfunction [params1, paramsN] -app app
PHP Fatal error: Class 'Controller' not found in /var/www/app/Controller/AppController.php on line 6
www-data#
So here is a summary of the problem I'm occurring right now…
Any idea how to solve this weird behavior?
Thanks.
Ok, so no one found how to help, but I did it myself ;)
For those experiencing a such behavior, I would recommend you to verify the system PATHS set as variable into your code.
In my case, into bootstrap.php, I've a WWW_PATH define which contains the local path to reach the base of the code directory.
define('WWW_PATH', '/home/foo/www-prod/www/');
In reality, my code directory is located under /var/www-prod/www/, and /home/foo/www-prod is just a unix symbolic link.
It seems that CakePhp Shell cannot load properly ressource with a BASE_DIR using a symbolic link, because after altering my code without this symbolic link into the path, it worked!