Compare commits
3 Commits
f31103d1d8
...
efaa9759c9
Author | SHA1 | Date | |
---|---|---|---|
efaa9759c9 | |||
845230529c | |||
26ec0e38b2 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
*.log
|
||||
*.cron
|
||||
|
3
crontabd/build.sh
Normal file
3
crontabd/build.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
nssm stop crontabd
|
||||
go build .
|
||||
nssm start crontabd
|
BIN
crontabd/crontabd.exe
(Stored with Git LFS)
BIN
crontabd/crontabd.exe
(Stored with Git LFS)
Binary file not shown.
@@ -119,7 +119,7 @@ func loadCronJobs() error {
|
||||
|
||||
func createJobFunc(job CronJob) func() {
|
||||
return func() {
|
||||
cmd := exec.Command("sh", "-c", job.Command)
|
||||
cmd := exec.Command(job.Command)
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
logger.Error("Failed to execute command '%s': %v", job.Command, err)
|
||||
@@ -133,17 +133,31 @@ func createJobFunc(job CronJob) func() {
|
||||
|
||||
func resolveCrontabPath() (string, error) {
|
||||
// Resolve crontab file location
|
||||
homeDir, err := os.UserHomeDir()
|
||||
// homeDir, err := os.UserHomeDir()
|
||||
// if err != nil {
|
||||
// return "", fmt.Errorf("failed to get user home directory: %v", err)
|
||||
// }
|
||||
// userName := os.Getenv("USERNAME")
|
||||
// crontabFile = filepath.Join(homeDir, "crontab", userName+".cron")
|
||||
// crontabFile, err = filepath.Abs(crontabFile)
|
||||
// if err != nil {
|
||||
// return "", fmt.Errorf("failed to get absolute path: %v", err)
|
||||
// }
|
||||
// crontabFile = filepath.Clean(crontabFile)
|
||||
|
||||
// Never mind this fucking noise
|
||||
// When running shit with nssm we have to run it with a system account
|
||||
// And the home of that one is deep within system32
|
||||
// I'm not going to poke around in system32
|
||||
// To make it run with the local account requires the password of the account
|
||||
// Even if the account has no fucking password
|
||||
// So we're just going to look for it in the cwd and call it a day
|
||||
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get user home directory: %v", err)
|
||||
return "", fmt.Errorf("failed to get current working directory: %v", err)
|
||||
}
|
||||
userName := os.Getenv("USERNAME")
|
||||
crontabFile = filepath.Join(homeDir, "crontab", userName+".cron")
|
||||
crontabFile, err = filepath.Abs(crontabFile)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get absolute path: %v", err)
|
||||
}
|
||||
crontabFile = filepath.Clean(crontabFile)
|
||||
crontabFile = filepath.Join(cwd, "crontab.cron")
|
||||
return crontabFile, nil
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,7 @@ nssm install crontabd 'C:\Users\Administrator\Seafile\Projects-Go\GoProjects\cro
|
||||
nssm set crontabd AppDirectory 'C:\Users\Administrator\Seafile\Projects-Go\GoProjects\crontab\crontabd'
|
||||
nssm set crontabd AppExit Default Restart
|
||||
nssm set crontabd DisplayName crontabd
|
||||
nssm set crontabd AppEnvironmentExtra :PATH='C:\Users\Administrator\scoop\shims'
|
||||
nssm set crontabd ObjectName LocalSystem
|
||||
nssm set crontabd Start SERVICE_AUTO_START
|
||||
nssm set crontabd Type SERVICE_WIN32_OWN_PROCESS
|
||||
|
Reference in New Issue
Block a user